#!/bin/sh # Helper script for git-shell to delete bare repositories # Usage: ssh code@host delete-repo if [ $# -ne 1 ]; then echo "Usage: delete-repo " 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