-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jc/upload-pack-hook: upload-pack: feed "kind [clone|fetch]" to post-upload-pack hook upload-pack: add a trigger for post-upload-pack hook
- Loading branch information
Showing
4 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/sh | ||
|
||
test_description='post upload-hook' | ||
|
||
. ./test-lib.sh | ||
|
||
LOGFILE=".git/post-upload-pack-log" | ||
|
||
test_expect_success setup ' | ||
test_commit A && | ||
test_commit B && | ||
git reset --hard A && | ||
test_commit C && | ||
git branch prev B && | ||
mkdir -p .git/hooks && | ||
{ | ||
echo "#!$SHELL_PATH" && | ||
echo "cat >post-upload-pack-log" | ||
} >".git/hooks/post-upload-pack" && | ||
chmod +x .git/hooks/post-upload-pack | ||
' | ||
|
||
test_expect_success initial ' | ||
rm -fr sub && | ||
git init sub && | ||
( | ||
cd sub && | ||
git fetch --no-tags .. prev | ||
) && | ||
want=$(sed -n "s/^want //p" "$LOGFILE") && | ||
test "$want" = "$(git rev-parse --verify B)" && | ||
! grep "^have " "$LOGFILE" && | ||
kind=$(sed -n "s/^kind //p" "$LOGFILE") && | ||
test "$kind" = fetch | ||
' | ||
|
||
test_expect_success second ' | ||
rm -fr sub && | ||
git init sub && | ||
( | ||
cd sub && | ||
git fetch --no-tags .. prev:refs/remotes/prev && | ||
git fetch --no-tags .. master | ||
) && | ||
want=$(sed -n "s/^want //p" "$LOGFILE") && | ||
test "$want" = "$(git rev-parse --verify C)" && | ||
have=$(sed -n "s/^have //p" "$LOGFILE") && | ||
test "$have" = "$(git rev-parse --verify B)" && | ||
kind=$(sed -n "s/^kind //p" "$LOGFILE") && | ||
test "$kind" = fetch | ||
' | ||
|
||
test_expect_success all ' | ||
rm -fr sub && | ||
HERE=$(pwd) && | ||
git init sub && | ||
( | ||
cd sub && | ||
git clone "file://$HERE/.git" new | ||
) && | ||
sed -n "s/^want //p" "$LOGFILE" | sort >actual && | ||
git rev-parse A B C | sort >expect && | ||
test_cmp expect actual && | ||
! grep "^have " "$LOGFILE" && | ||
kind=$(sed -n "s/^kind //p" "$LOGFILE") && | ||
test "$kind" = clone | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters