aboutsummaryrefslogtreecommitdiff
path: root/git-shell-commands/new-repo
diff options
context:
space:
mode:
authorTrey Bastian <hello@treybastian.com>2026-04-09 20:59:08 +0100
committerTrey Bastian <hello@treybastian.com>2026-04-09 20:59:08 +0100
commited75014df6e75b44ee8a31bcedf53fda63fcba7e (patch)
tree2e9924e5881b862eea4371a4064975c6db5722a3 /git-shell-commands/new-repo
parentb0684c87580926fa00c221afcc4461ca812390a0 (diff)
added support for a description and testing out claude
Diffstat (limited to 'git-shell-commands/new-repo')
-rwxr-xr-xgit-shell-commands/new-repo30
1 files changed, 26 insertions, 4 deletions
diff --git a/git-shell-commands/new-repo b/git-shell-commands/new-repo
index c2c454a..80f7ec9 100755
--- a/git-shell-commands/new-repo
+++ b/git-shell-commands/new-repo
@@ -3,27 +3,45 @@ set -euo pipefail
# this script creates a bare git repository on the git server
#
# USAGE:
-# ssh git@<host> new-repo <name>
+# ssh git@<host> new-repo <name> [--description <desc>]
#
# EXAMPLES:
# ssh git@treybastian.com new-repo myrepo
# ssh git@treybastian.com new-repo myrepo.git
+# ssh git@treybastian.com new-repo myrepo --description "my cool repo"
usage() {
- echo "Usage: new-repo <name>"
+ echo "Usage: new-repo <name> [--description <desc>]"
echo ""
echo "Examples:"
echo " new-repo myrepo"
echo " new-repo myrepo.git"
+ echo " new-repo myrepo --description \"my cool repo\""
exit 1
}
-if [ "$#" -ne 1 ]; then
- echo "Error: expected 1 argument, got $#"
+if [ "$#" -lt 1 ]; then
+ echo "Error: expected at least 1 argument, got $#"
usage
fi
PROJECT_NAME="$1"
+DESCRIPTION=""
+shift
+
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --description)
+ [ "$#" -ge 2 ] || { echo "Error: --description requires a value"; usage; }
+ DESCRIPTION="$2"
+ shift 2
+ ;;
+ *)
+ echo "Error: unknown flag '$1'"
+ usage
+ ;;
+ esac
+done
if [[ "$PROJECT_NAME" != *.git ]]; then
PROJECT_NAME="${PROJECT_NAME}.git"
@@ -36,6 +54,10 @@ fi
git --bare init "$PROJECT_NAME"
+if [ -n "$DESCRIPTION" ]; then
+ echo "$DESCRIPTION" > "${PROJECT_NAME}/description"
+fi
+
echo "repo created: $PROJECT_NAME"
echo "git url: ${USER}@${HOSTNAME}:${PROJECT_NAME}"