git-lfs/test/test-uninstall.sh

109 lines
2.5 KiB
Bash
Raw Normal View History

2015-07-30 02:37:31 +00:00
#!/usr/bin/env bash
2015-07-10 16:43:20 +00:00
. "test/testlib.sh"
2015-11-16 20:37:08 +00:00
begin_test "uninstall outside repository"
2015-07-10 16:43:20 +00:00
(
set -e
smudge="$(git config filter.lfs.smudge)"
clean="$(git config filter.lfs.clean)"
printf "$smudge" | grep "git-lfs smudge"
printf "$clean" | grep "git-lfs clean"
2015-07-10 16:43:20 +00:00
2015-11-16 20:37:08 +00:00
# uninstall multiple times to trigger https://github.com/github/git-lfs/issues/529
git lfs uninstall
2015-11-18 18:27:00 +00:00
git lfs install
2015-11-16 20:37:08 +00:00
git lfs uninstall | tee uninstall.log
grep "configuration has been removed" uninstall.log
2015-07-10 16:43:20 +00:00
[ "" = "$(git config --global filter.lfs.smudge)" ]
[ "" = "$(git config --global filter.lfs.clean)" ]
cat $HOME/.gitconfig
[ "$(grep 'filter "lfs"' $HOME/.gitconfig -c)" = "0" ]
2015-07-10 16:43:20 +00:00
)
end_test
2015-11-16 20:37:08 +00:00
begin_test "uninstall inside repository with default pre-push hook"
2015-07-10 16:43:20 +00:00
(
set -e
reponame="$(basename "$0" ".sh")-hook"
mkdir "$reponame"
cd "$reponame"
git init
2015-11-18 18:27:00 +00:00
git lfs install
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ]
grep "git-lfs" .git/hooks/pre-push
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
2015-07-10 16:43:20 +00:00
2015-11-16 20:37:08 +00:00
git lfs uninstall
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ] && {
echo "expected .git/hooks/pre-push to be deleted"
exit 1
}
[ "" = "$(git config filter.lfs.smudge)" ]
[ "" = "$(git config filter.lfs.clean)" ]
)
end_test
2015-11-16 20:37:08 +00:00
begin_test "uninstall inside repository without git lfs pre-push hook"
2015-07-10 16:43:20 +00:00
(
set -e
reponame="$(basename "$0" ".sh")-no-hook"
mkdir "$reponame"
cd "$reponame"
git init
2015-11-18 18:27:00 +00:00
git lfs install
echo "something something git-lfs" > .git/hooks/pre-push
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ]
[ "something something git-lfs" = "$(cat .git/hooks/pre-push)" ]
2015-07-10 16:43:20 +00:00
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
2015-07-10 16:43:20 +00:00
2015-11-16 20:37:08 +00:00
git lfs uninstall
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ]
[ "" = "$(git config filter.lfs.smudge)" ]
[ "" = "$(git config filter.lfs.clean)" ]
)
end_test
2015-11-16 20:37:08 +00:00
begin_test "uninstall hooks inside repository"
2015-07-10 16:43:20 +00:00
(
set -e
reponame="$(basename "$0" ".sh")-only-hook"
mkdir "$reponame"
cd "$reponame"
git init
2015-11-18 18:27:00 +00:00
git lfs install
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ]
grep "git-lfs" .git/hooks/pre-push
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
2015-07-10 16:43:20 +00:00
2015-11-16 20:37:08 +00:00
git lfs uninstall hooks
2015-07-10 16:43:20 +00:00
[ -f .git/hooks/pre-push ] && {
echo "expected .git/hooks/pre-push to be deleted"
exit 1
}
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
2015-07-10 16:43:20 +00:00
)
end_test