From: Oleg Broytman Date: Sun, 24 Dec 2023 09:57:30 +0000 (+0300) Subject: Feat: Delete a repository X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=b3a97851e17d472c9bbb3e738647569c655cf6ea Feat: Delete a repository Mostly for deleting it from `locate-all.list`. --- diff --git a/delete b/delete new file mode 100755 index 0000000..6002dc4 --- /dev/null +++ b/delete @@ -0,0 +1,28 @@ +#! /bin/sh + +if [ -z "$1" -o -n "$3" ]; then + echo "Usage: $0 /path/to/repo" >&2 + exit 1 +fi + +start_dir="`pwd`" && +path_to_repo="$1" && +cd "$path_to_repo" && +path_to_repo="`pwd`" && +cd "$start_dir" && + +cd "`dirname \"$0\"`" && +if ! grep -q "^$path_to_repo\$" locate-all.list; then + echo "$path_to_repo" is not a known repository >&2 + exit 1 +fi + +rm -rf "$path_to_repo" && + +tmpfile="`mktemp`" && +grep -v "^$path_to_repo\$" locate-all.list > "$tmpfile" && +if cmp -s mv "$tmpfile" locate-all.list; then + exec rm -f "$tmpfile" +else + exec mv "$tmpfile" locate-all.list +fi