git foo will automatically install and run git-foo (#3537)

This commit is contained in:
Max Howell 2023-10-05 13:52:36 -04:00 committed by GitHub
parent 0d2e40d20a
commit 85a0f8857a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 42 deletions

View file

@ -3,5 +3,4 @@
"deno.lint": true,
"deno.unstable": true,
"deno.config": ".github/deno.jsonc",
"deno.importMap": "../cli/import-map.json"
}

31
projects/git-scm.org/git-shim Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
set -e
find_git_command() {
for arg in "$@"; do
case $arg in
-*);;
*)
echo $arg
return # found the command!
esac
done
}
libexec="$(cd "$(dirname "$0")/.." && pwd)"/libexec
# extract the git subcommand
cmd=$(find_git_command "$@")
if [ -z "$cmd" ]; then
exec "$libexec/git" "$@"
elif [ -x "$libexec/git-$_CMD" -a -f "$libexec/git-$cmd" ]; then
exec "$libexec/git" "$@"
elif type "git-$cmd" >/dev/null 2>&1; then
exec "$libexec/git" "$@"
elif command -v pkgx >/dev/null 2>&1 && pkg=$(pkgx --provider git-$cmd); then
exec pkgx +$pkg "$libexec/git" "$@"
else
exec "$libexec/git" "$@"
fi

View file

@ -12,6 +12,7 @@ dependencies:
curl.se/ca-certs: '*'
perl.org: '*'
libexpat.github.io: ~2
pkgx.sh: ^1
runtime:
env:
@ -19,65 +20,76 @@ runtime:
GIT_SSL_CAINFO: ${{deps.curl.se/ca-certs.prefix}}/ssl/cert.pem
build:
script: |
mv props/config.mak .
script:
- mv props/config.mak .
./configure $CONF
make install $BAKE
- ./configure
--prefix={{ prefix }}
--with-perl={{ deps.perl.org.prefix }}
--with-gitconfig=etc/gitconfig
cd contrib/subtree
- make install --jobs {{ hw.concurrency }} NO_TCLTK=1
- run: |
make
make install
working-directory: contrib/subtree
if test "{{ hw.platform }}" = "darwin"; then
cd "$SRCROOT/contrib/credential/osxkeychain"
- run: |
make
mv git-credential-osxkeychain "{{prefix}}"/bin
make clean
cd "$SRCROOT/contrib/subtree"
fi
working-directory: contrib/credential/osxkeychain
if: darwin
mv git-subtree "{{prefix}}"/libexec
- run: mv git-subtree "{{prefix}}"/libexec
working-directory: contrib/subtree
cd "{{prefix}}"
DEBUG=1 fix-shebangs.ts bin/* libexec/*
- run: fix-shebangs.ts bin/* libexec/*
working-directory: ${{prefix}}
mkdir -p etc
cp "$SRCROOT"/props/git* etc
- run: cp "$SRCROOT"/props/gitconfig "$SRCROOT"/props/gitignore .
working-directory: ${{prefix}}/etc
- run: |
rm bin/git
cp $SRCROOT/props/git-shim bin/git
working-directory: ${{prefix}}
env:
V: 1
BAKE:
- --jobs {{ hw.concurrency }}
- NO_TCLTK=1
CONF:
- --prefix={{ prefix }}
- --with-perl={{ deps.perl.org.prefix }}
- --with-gitconfig=etc/gitconfig
INSTALL_STRIP: -s
test: |
git clone https://github.com/teaxyz/white-paper 2>&1 | tee clone-output.txt
test:
# bug in pkgx where it doesnt auto sync for --provides
- pkgx --sync
# check that the templates can be found
- run: |
git clone https://github.com/teaxyz/white-paper 2>&1 | tee clone-output.txt
if grep -q 'warning: templates not found in' clone-output.txt; then
false
exit 1
fi
working-directory: $(mktemp -d)
mkdir foo
cd foo
- cd $(mktemp -d)
- run: |
touch .DS_Store testfile
git init
git add .
test "$(git diff --name-only --cached)" = "testfile"
# necessary so `git commit` will work
- |
git config user.email "you@example.com"
git config user.name "Your Name"
# necessary to check the libexec binaries work
git commit --message "test"
- git commit --message "test"
git subtree add --prefix teaxyz-subtree https://github.com/teaxyz/white-paper main --squash
- git subtree add --prefix teaxyz-subtree https://github.com/teaxyz/white-paper main --squash
- git gone --version
provides:
linux: