Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
"deno.lint": true,
"deno.unstable": true,
"deno.config": ".github/deno.jsonc",
"deno.importMap": "../cli/import-map.json"
}
31 changes: 31 additions & 0 deletions projects/git-scm.org/git-shim
Original file line number Diff line number Diff line change
@@ -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
94 changes: 53 additions & 41 deletions projects/git-scm.org/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,72 +12,84 @@ dependencies:
curl.se/ca-certs: '*'
perl.org: '*'
libexpat.github.io: ~2
pkgx.sh: ^1

runtime:
env:
GIT_TEMPLATE_DIR: '{{prefix}}/share/git-core/templates'
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
make install
- make install --jobs {{ hw.concurrency }} NO_TCLTK=1

if test "{{ hw.platform }}" = "darwin"; then
cd "$SRCROOT/contrib/credential/osxkeychain"
make
mv git-credential-osxkeychain "{{prefix}}"/bin
make clean
cd "$SRCROOT/contrib/subtree"
fi
- run: |
make
make install
working-directory: contrib/subtree

mv git-subtree "{{prefix}}"/libexec
- run: |
make
mv git-credential-osxkeychain "{{prefix}}"/bin
make clean
working-directory: contrib/credential/osxkeychain
if: darwin

cd "{{prefix}}"
DEBUG=1 fix-shebangs.ts bin/* libexec/*
- run: mv git-subtree "{{prefix}}"/libexec
working-directory: contrib/subtree

mkdir -p etc
cp "$SRCROOT"/props/git* etc
- run: fix-shebangs.ts bin/* libexec/*
working-directory: ${{prefix}}

- 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 doesn’t auto sync for --provides
- pkgx --sync

# check that the templates can be found
if grep -q 'warning: templates not found in' clone-output.txt; then
false
fi
- 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
exit 1
fi
working-directory: $(mktemp -d)

mkdir foo
cd foo
touch .DS_Store testfile
git init
git add .
test "$(git diff --name-only --cached)" = "testfile"
- 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"
- |
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:
Expand Down