git-lfs/test/test-uninit.sh

130 lines
2.8 KiB
Bash
Raw Normal View History

2015-07-10 16:43:20 +00:00
#!/bin/sh
. "test/testlib.sh"
begin_test "uninit outside repository"
(
set -e
2015-07-10 17:08:53 +00:00
tmphome="$(basename "$0" ".sh")"
mkdir -p $tmphome
cp $HOME/.gitconfig $tmphome/
HOME=$PWD/$tmphome
cd $HOME
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)" ]
# uninit multiple times to trigger https://github.com/github/git-lfs/issues/529
git lfs uninit
git lfs init
2015-07-10 16:43:20 +00:00
git lfs uninit | tee uninit.log
grep "configuration has been removed" uninit.log
[ "" = "$(git config filter.lfs.smudge)" ]
[ "" = "$(git config filter.lfs.clean)" ]
cat $HOME/.gitconfig
[ "$(grep 'filter "lfs"' $HOME/.gitconfig -c)" = "0" ]
2015-07-10 16:43:20 +00:00
)
end_test
begin_test "uninit inside repository with default pre-push hook"
(
set -e
2015-07-10 17:08:53 +00:00
tmphome="$(basename "$0" ".sh")"
mkdir -p $tmphome
cp $HOME/.gitconfig $tmphome/
HOME=$PWD/$tmphome
cd $HOME
2015-07-10 16:43:20 +00:00
reponame="$(basename "$0" ".sh")-hook"
mkdir "$reponame"
cd "$reponame"
git init
git lfs init
[ -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 uninit
[ -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
begin_test "uninit inside repository without git lfs pre-push hook"
(
set -e
2015-07-10 17:08:53 +00:00
tmphome="$(basename "$0" ".sh")"
mkdir -p $tmphome
cp $HOME/.gitconfig $tmphome/
HOME=$PWD/$tmphome
cd $HOME
2015-07-10 16:43:20 +00:00
reponame="$(basename "$0" ".sh")-no-hook"
mkdir "$reponame"
cd "$reponame"
git init
git lfs init
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)" ]
git lfs uninit
[ -f .git/hooks/pre-push ]
[ "" = "$(git config filter.lfs.smudge)" ]
[ "" = "$(git config filter.lfs.clean)" ]
)
end_test
begin_test "uninit hooks inside repository"
(
set -e
2015-07-10 17:08:53 +00:00
tmphome="$(basename "$0" ".sh")"
mkdir -p $tmphome
cp $HOME/.gitconfig $tmphome/
HOME=$PWD/$tmphome
cd $HOME
2015-07-10 16:43:20 +00:00
reponame="$(basename "$0" ".sh")-only-hook"
mkdir "$reponame"
cd "$reponame"
git init
git lfs init
[ -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 uninit hooks
[ -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)" ]
)
end_test