github.com/q2/git-lfs@v0.5.1-0.20150410234700-03a0d4cec40e/script/clean-git-test-fixture (about) 1 #!/bin/sh 2 #/ Usage: script/clean-git-test-fixture <path.git> 3 set -e 4 5 path="${1%/}" 6 7 # bail out if path not specified 8 if [ -z "$path" ] 9 then 10 echo "$(basename $0): path not specified" 1>&2 11 exit 1 12 fi 13 14 # make sure the repo we're cleaning already exists. 15 if ! [ -d "$path" ] 16 then 17 echo "$(basename $0): $path does not exist" 18 exit 1 19 fi 20 21 # all the superfluous git file names 22 # note: in most cases, it would be fine to just delete the hooks folder, but 23 # some tests rely on real hooks, so just delete the sample hooks. 24 superfluous_git_files=" 25 COMMIT_EDITMSG 26 hooks/applypatch-msg.sample 27 hooks/commit-msg.sample 28 hooks/post-update.sample 29 hooks/pre-applypatch.sample 30 hooks/pre-commit.sample 31 hooks/pre-push.sample 32 hooks/pre-rebase.sample 33 hooks/prepare-commit-msg.sample 34 hooks/update.sample 35 index 36 info/exclude 37 " 38 39 for filename in $superfluous_git_files 40 do 41 filepath="$path/$filename" 42 43 if [ -e "$filepath" ] 44 then 45 if [ -d "$filepath" ] 46 then 47 # If the thing at $filepath is a directory, delete it recursively. 48 rm -r "$filepath" 49 echo "Deleted dir at $filepath" 50 else 51 # If the thing at $filepath is a file, delete it the normal way. 52 rm "$filepath" 53 echo "Deleted file at $filepath" 54 fi 55 fi 56 done