Merge pull request #339 from github/prepush
Make the pre-push hook check that git-lfs exists first
This commit is contained in:
commit
5ebb953e01
@ -17,10 +17,11 @@ var (
|
|||||||
valueRegexp = regexp.MustCompile("\\Agit[\\-\\s]media")
|
valueRegexp = regexp.MustCompile("\\Agit[\\-\\s]media")
|
||||||
NotInARepositoryError = errors.New("Not in a repository")
|
NotInARepositoryError = errors.New("Not in a repository")
|
||||||
|
|
||||||
prePushHook = "#!/bin/sh\ngit lfs pre-push \"$@\""
|
prePushHook = "#!/bin/sh\ncommand -v git-lfs >/dev/null 2>&1 || { echo >&2 \"\\nThis repository has been set up with Git LFS but Git LFS is not installed.\\n\"; exit 0; }\ngit lfs pre-push \"$@\""
|
||||||
prePushUpgrades = map[string]bool{
|
prePushUpgrades = map[string]bool{
|
||||||
"#!/bin/sh\ngit lfs push --stdin $*": true,
|
"#!/bin/sh\ngit lfs push --stdin $*": true,
|
||||||
"#!/bin/sh\ngit lfs push --stdin \"$@\"": true,
|
"#!/bin/sh\ngit lfs push --stdin \"$@\"": true,
|
||||||
|
"#!/bin/sh\ngit lfs pre-push \"$@\"": true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ begin_test "update"
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
pre_push_hook="#!/bin/sh
|
pre_push_hook="#!/bin/sh
|
||||||
|
command -v git-lfs >/dev/null 2>&1 || { echo >&2 \"\\nThis repository has been set up with Git LFS but Git LFS is not installed.\\n\"; exit 0; }
|
||||||
git lfs pre-push \"\$@\""
|
git lfs pre-push \"\$@\""
|
||||||
|
|
||||||
mkdir without-pre-push
|
mkdir without-pre-push
|
||||||
@ -33,6 +34,12 @@ git lfs push --stdin \"\$@\"" > .git/hooks/pre-push
|
|||||||
[ "Updated pre-push hook" = "$(git lfs update)" ]
|
[ "Updated pre-push hook" = "$(git lfs update)" ]
|
||||||
[ "$pre_push_hook" = "$(cat .git/hooks/pre-push)" ]
|
[ "$pre_push_hook" = "$(cat .git/hooks/pre-push)" ]
|
||||||
|
|
||||||
|
# replace old hook 3
|
||||||
|
echo "#!/bin/sh
|
||||||
|
git lfs pre-push \"\$@\"" > .git/hooks/pre-push
|
||||||
|
[ "Updated pre-push hook" = "$(git lfs update)" ]
|
||||||
|
[ "$pre_push_hook" = "$(cat .git/hooks/pre-push)" ]
|
||||||
|
|
||||||
# don't replace unexpected hook
|
# don't replace unexpected hook
|
||||||
echo "test" > .git/hooks/pre-push
|
echo "test" > .git/hooks/pre-push
|
||||||
expected="Hook already exists: pre-push
|
expected="Hook already exists: pre-push
|
||||||
|
Loading…
Reference in New Issue
Block a user