#!/bin/sh #/ Usage: script/clean-git-test-fixture set -e path="${1%/}" # bail out if path not specified if [ -z "$path" ] then echo "$(basename $0): path not specified" 1>&2 exit 1 fi # make sure the repo we're cleaning already exists. if ! [ -d "$path" ] then echo "$(basename $0): $path does not exist" exit 1 fi # all the superfluous git file names # note: in most cases, it would be fine to just delete the hooks folder, but # some tests rely on real hooks, so just delete the sample hooks. superfluous_git_files=" COMMIT_EDITMSG hooks/applypatch-msg.sample hooks/commit-msg.sample hooks/post-update.sample hooks/pre-applypatch.sample hooks/pre-commit.sample hooks/pre-push.sample hooks/pre-rebase.sample hooks/prepare-commit-msg.sample hooks/update.sample index info/exclude " for filename in $superfluous_git_files do filepath="$path/$filename" if [ -e "$filepath" ] then if [ -d "$filepath" ] then # If the thing at $filepath is a directory, delete it recursively. rm -r "$filepath" echo "Deleted dir at $filepath" else # If the thing at $filepath is a file, delete it the normal way. rm "$filepath" echo "Deleted file at $filepath" fi fi done