From e9fccc7c9374c0129159282f0c7f4619a390e8a2 Mon Sep 17 00:00:00 2001 From: Mauricio Pasquier Juan Date: Tue, 10 Sep 2013 21:22:46 -0300 Subject: command to delete repositories --- git-shell-commands/delete-repo | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 git-shell-commands/delete-repo (limited to 'git-shell-commands/delete-repo') diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo new file mode 100755 index 0000000..8349308 --- /dev/null +++ b/git-shell-commands/delete-repo @@ -0,0 +1,13 @@ +#!/bin/sh +# * delete-repo +# Allows users to delete repositories permanently +# ssh git@host delete-repo repo1 repo2 ... + +set -e + +for i in $@; do + if [ -z "$repo" ]; then continue; fi + + # lo and behold absolute horror + rm -rf "$repo".git +done -- cgit v1.2.3-2-g168b From 56bbf899a62e6ebf33a4c2dd2b1b1bd7e1b6da72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 11 Sep 2013 01:14:04 -0300 Subject: The var is repo --- git-shell-commands/delete-repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-shell-commands/delete-repo') diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo index 8349308..5731272 100755 --- a/git-shell-commands/delete-repo +++ b/git-shell-commands/delete-repo @@ -5,7 +5,7 @@ set -e -for i in $@; do +for repo in $@; do if [ -z "$repo" ]; then continue; fi # lo and behold absolute horror -- cgit v1.2.3-2-g168b From 977be1ea61943917b9def025d59b8ef493810452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 11 Sep 2013 01:19:13 -0300 Subject: test is nicer --- git-shell-commands/delete-repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-shell-commands/delete-repo') diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo index 5731272..1e4350e 100755 --- a/git-shell-commands/delete-repo +++ b/git-shell-commands/delete-repo @@ -6,7 +6,7 @@ set -e for repo in $@; do - if [ -z "$repo" ]; then continue; fi + test ! -d "$repo" && continue # lo and behold absolute horror rm -rf "$repo".git -- cgit v1.2.3-2-g168b From e731c2a87859cb97aa091b11589c63a6b7f5a12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 11 Sep 2013 01:23:45 -0300 Subject: Test for the actual repo --- git-shell-commands/delete-repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-shell-commands/delete-repo') diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo index 1e4350e..17804c6 100755 --- a/git-shell-commands/delete-repo +++ b/git-shell-commands/delete-repo @@ -6,7 +6,7 @@ set -e for repo in $@; do - test ! -d "$repo" && continue + test ! -d "$repo".git && continue # lo and behold absolute horror rm -rf "$repo".git -- cgit v1.2.3-2-g168b From 34b2ef6f3896d54436c24282c39145c5ee5c45c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 11 Sep 2013 01:27:16 -0300 Subject: A bit more secure --- git-shell-commands/delete-repo | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-shell-commands/delete-repo') diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo index 17804c6..075f77a 100755 --- a/git-shell-commands/delete-repo +++ b/git-shell-commands/delete-repo @@ -6,8 +6,11 @@ set -e for repo in $@; do +# Remove leading slashes and dots and perform cleanup + repo="`echo "$repo" | sed -e "s,^[/\.]\+,,g" -e "s,[^a-z0-9\./_-],,gi"`" test ! -d "$repo".git && continue + echo "Removing ${repo}.git" # lo and behold absolute horror rm -rf "$repo".git done -- cgit v1.2.3-2-g168b