2015-07-30 02:37:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-07-10 16:43:20 +00:00
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2015-07-10 16:43:20 +00:00
|
|
|
|
2015-11-16 20:37:08 +00:00
|
|
|
begin_test "uninstall outside repository"
|
2015-07-10 16:43:20 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2016-11-30 20:43:46 +00:00
|
|
|
mkdir uninstall-test
|
|
|
|
cd uninstall-test
|
|
|
|
|
2015-10-26 23:12:15 +00:00
|
|
|
smudge="$(git config filter.lfs.smudge)"
|
|
|
|
clean="$(git config filter.lfs.clean)"
|
2016-11-08 14:44:51 +00:00
|
|
|
filter="$(git config filter.lfs.process)"
|
2015-10-26 23:12:15 +00:00
|
|
|
|
2018-09-10 14:57:10 +00:00
|
|
|
printf "%s" "$smudge" | grep "git-lfs smudge"
|
|
|
|
printf "%s" "$clean" | grep "git-lfs clean"
|
|
|
|
printf "%s" "$filter" | grep "git-lfs filter-process"
|
2015-07-10 16:43:20 +00:00
|
|
|
|
2016-11-15 17:07:11 +00:00
|
|
|
# uninstall multiple times to trigger https://github.com/git-lfs/git-lfs/issues/529
|
2015-11-16 20:37:08 +00:00
|
|
|
git lfs uninstall
|
2016-11-30 20:43:46 +00:00
|
|
|
|
|
|
|
[ ! -e "lfs" ]
|
|
|
|
|
2018-10-17 18:53:04 +00:00
|
|
|
for opt in "" "--skip-repo"
|
|
|
|
do
|
|
|
|
git lfs install
|
|
|
|
git lfs uninstall $opt | tee uninstall.log
|
|
|
|
grep "configuration has been removed" uninstall.log
|
|
|
|
|
|
|
|
[ "" = "$(git config --global filter.lfs.smudge)" ]
|
|
|
|
[ "" = "$(git config --global filter.lfs.clean)" ]
|
|
|
|
[ "" = "$(git config --global filter.lfs.process)" ]
|
|
|
|
|
|
|
|
cat $HOME/.gitconfig
|
|
|
|
[ "$(grep 'filter "lfs"' $HOME/.gitconfig -c)" = "0" ]
|
|
|
|
done
|
2015-07-10 16:43:20 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-11-30 20:43:46 +00:00
|
|
|
begin_test "uninstall outside repository without access to .git/lfs"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
mkdir uninstall-no-lfs
|
|
|
|
cd uninstall-no-lfs
|
|
|
|
|
|
|
|
mkdir .git
|
|
|
|
touch .git/lfs
|
|
|
|
touch lfs
|
|
|
|
|
|
|
|
[ "" != "$(git config --global filter.lfs.smudge)" ]
|
|
|
|
[ "" != "$(git config --global filter.lfs.clean)" ]
|
|
|
|
[ "" != "$(git config --global filter.lfs.process)" ]
|
|
|
|
|
|
|
|
git lfs uninstall
|
|
|
|
|
|
|
|
[ "" = "$(git config --global filter.lfs.smudge)" ]
|
|
|
|
[ "" = "$(git config --global filter.lfs.clean)" ]
|
|
|
|
[ "" = "$(git config --global filter.lfs.process)" ]
|
|
|
|
)
|
|
|
|
|
2018-10-17 18:53:04 +00:00
|
|
|
begin_test "uninstall inside repository with --skip-repo"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-skip-repo"
|
|
|
|
mkdir "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
git init
|
|
|
|
git lfs install
|
|
|
|
|
|
|
|
[ -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)" ]
|
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
|
|
|
|
|
|
|
git lfs uninstall --skip-repo
|
|
|
|
|
|
|
|
[ -f .git/hooks/pre-push ]
|
|
|
|
[ "" = "$(git config filter.lfs.smudge)" ]
|
|
|
|
[ "" = "$(git config filter.lfs.clean)" ]
|
|
|
|
[ "" = "$(git config filter.lfs.process)" ]
|
|
|
|
)
|
|
|
|
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
|
|
|
|
|
2016-03-17 21:25:33 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
|
|
|
|
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
|
2016-11-08 20:05:12 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
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)" ]
|
2016-11-08 14:44:51 +00:00
|
|
|
[ "" = "$(git config filter.lfs.process)" ]
|
2015-07-10 16:43:20 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2017-01-25 13:32:39 +00:00
|
|
|
begin_test "uninstall inside repository without 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
|
2015-07-10 16:53:06 +00:00
|
|
|
echo "something something git-lfs" > .git/hooks/pre-push
|
2015-07-10 16:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
[ -f .git/hooks/pre-push ]
|
2015-07-10 16:53:06 +00:00
|
|
|
[ "something something git-lfs" = "$(cat .git/hooks/pre-push)" ]
|
2015-07-10 16:43:20 +00:00
|
|
|
|
2016-03-17 21:25:33 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
|
|
|
|
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
|
2016-11-08 20:05:12 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
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)" ]
|
2016-11-08 14:44:51 +00:00
|
|
|
[ "" = "$(git config filter.lfs.process)" ]
|
2015-07-10 16:43:20 +00:00
|
|
|
)
|
|
|
|
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
|
|
|
|
|
2016-03-17 21:25:33 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
|
|
|
|
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
|
2016-11-08 20:05:12 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
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
|
|
|
|
}
|
|
|
|
|
2016-03-17 21:25:33 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
|
|
|
|
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
|
2016-11-08 20:05:12 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
2015-07-10 16:43:20 +00:00
|
|
|
)
|
|
|
|
end_test
|
2017-01-24 23:33:29 +00:00
|
|
|
|
2020-06-16 19:25:51 +00:00
|
|
|
begin_test "uninstall --local outside repository"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# If run inside the git-lfs source dir this will update its .git/config & cause issues
|
|
|
|
if [ "$GIT_LFS_TEST_DIR" == "" ]; then
|
|
|
|
echo "Skipping uninstall --local because GIT_LFS_TEST_DIR is not set"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
has_test_dir || exit 0
|
|
|
|
|
|
|
|
set +e
|
|
|
|
git lfs uninstall --local >out.log
|
|
|
|
res=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[ "Not in a git repository." = "$(cat out.log)" ]
|
|
|
|
[ "0" != "$res" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "uninstall --local with conflicting scope"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-scope-conflict"
|
|
|
|
mkdir "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
git init
|
|
|
|
|
|
|
|
set +e
|
|
|
|
git lfs uninstall --local --system 2>err.log
|
|
|
|
res=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[ "Only one of --local and --system options can be specified." = "$(cat err.log)" ]
|
|
|
|
[ "0" != "$res" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2017-01-24 23:33:29 +00:00
|
|
|
begin_test "uninstall --local"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# old values that should be ignored by `uninstall --local`
|
|
|
|
git config --global filter.lfs.smudge "global smudge"
|
|
|
|
git config --global filter.lfs.clean "global clean"
|
|
|
|
git config --global filter.lfs.process "global filter"
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-local"
|
|
|
|
mkdir "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
git init
|
|
|
|
git lfs install --local
|
|
|
|
|
|
|
|
# local configs are correct
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "git-lfs smudge -- %f" = "$(git config --local filter.lfs.smudge)" ]
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "git-lfs clean -- %f" = "$(git config --local filter.lfs.clean)" ]
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "git-lfs filter-process" = "$(git config --local filter.lfs.process)" ]
|
|
|
|
|
|
|
|
# global configs
|
|
|
|
[ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
|
|
|
|
[ "global clean" = "$(git config --global filter.lfs.clean)" ]
|
|
|
|
[ "global filter" = "$(git config --global filter.lfs.process)" ]
|
|
|
|
|
2018-04-18 22:21:59 +00:00
|
|
|
git lfs uninstall --local 2>&1 | tee uninstall.log
|
|
|
|
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
|
|
|
echo >&2 "fatal: expected 'git lfs uninstall --local' to succeed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
grep -v "Global Git LFS configuration has been removed." uninstall.log
|
2017-01-24 23:33:29 +00:00
|
|
|
|
|
|
|
# global configs
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "global smudge" = "$(git config filter.lfs.smudge)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "global clean" = "$(git config filter.lfs.clean)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "global clean" = "$(git config --global filter.lfs.clean)" ]
|
2020-06-16 19:25:51 +00:00
|
|
|
[ "global filter" = "$(git config filter.lfs.process)" ]
|
2017-01-24 23:33:29 +00:00
|
|
|
[ "global filter" = "$(git config --global filter.lfs.process)" ]
|
|
|
|
|
|
|
|
# local configs are empty
|
|
|
|
[ "" = "$(git config --local filter.lfs.smudge)" ]
|
|
|
|
[ "" = "$(git config --local filter.lfs.clean)" ]
|
|
|
|
[ "" = "$(git config --local filter.lfs.process)" ]
|
|
|
|
)
|
|
|
|
end_test
|