diff options
| author | Elizabeth Hunt <me@liz.coffee> | 2025-12-05 21:43:18 -0800 |
|---|---|---|
| committer | Elizabeth Hunt <me@liz.coffee> | 2025-12-05 22:19:52 -0800 |
| commit | 8667f8615da479a8e9c4e8d5bb5987632d75bfaf (patch) | |
| tree | e3b4bdb4ebe4f0010c90dd43970822bbe8f8d4a6 /delete-repo | |
| parent | 4cde5dedcf35f2d5850ce0479f25d29bac74daf7 (diff) | |
| download | wwwgit-8667f8615da479a8e9c4e8d5bb5987632d75bfaf.tar.gz wwwgit-8667f8615da479a8e9c4e8d5bb5987632d75bfaf.zip | |
Add ssh server
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 |
