diff options
Diffstat (limited to 'delete-repo')
| -rw-r--r-- | delete-repo | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/delete-repo b/delete-repo new file mode 100644 index 0000000..0eecf4c --- /dev/null +++ b/delete-repo @@ -0,0 +1,47 @@ +#!/bin/sh +# Helper script for git-shell to delete bare repositories +# Usage: ssh code@host delete-repo <repo-name> + +if [ $# -ne 1 ]; then + echo "Usage: delete-repo <repo-name>" + echo "Example: delete-repo myproject.git" + exit 1 +fi + +REPO_NAME="$1" + +# Ensure it ends with .git +case "$REPO_NAME" in + *.git) ;; + *) REPO_NAME="${REPO_NAME}.git" ;; +esac + +REPO_DIR="$HOME/$REPO_NAME" + +if [ ! -e "$REPO_DIR" ]; then + echo "Error: Repository '$REPO_NAME' does not exist" + exit 1 +fi + +if [ ! -d "$REPO_DIR" ]; then + echo "Error: '$REPO_NAME' is not a directory" + exit 1 +fi + +# Safety check - make sure it looks like a git repository +if [ ! -f "$REPO_DIR/config" ] || [ ! -d "$REPO_DIR/objects" ]; then + echo "Error: '$REPO_NAME' does not appear to be a git repository" + exit 1 +fi + +echo "WARNING: This will permanently delete the repository '$REPO_NAME'" +echo "Type 'yes' to confirm deletion:" +read -r confirmation + +if [ "$confirmation" = "yes" ]; then + rm -rf "$REPO_DIR" + echo "Repository '$REPO_NAME' has been deleted" +else + echo "Deletion cancelled" + exit 1 +fi |
