From ed75014df6e75b44ee8a31bcedf53fda63fcba7e Mon Sep 17 00:00:00 2001 From: Trey Bastian Date: Thu, 9 Apr 2026 20:59:08 +0100 Subject: added support for a description and testing out claude --- git-shell-commands/set-description | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 git-shell-commands/set-description (limited to 'git-shell-commands/set-description') diff --git a/git-shell-commands/set-description b/git-shell-commands/set-description new file mode 100755 index 0000000..a6e8a50 --- /dev/null +++ b/git-shell-commands/set-description @@ -0,0 +1,51 @@ +#!/bin/bash +set -euo pipefail +# this script sets the description of an existing bare git repository +# if public.conf exists the description is also set on the remote repository +# +# USAGE: +# ssh git@ set-description +# +# EXAMPLES: +# ssh git@treybastian.com set-description myrepo "my cool repo" +# ssh git@treybastian.com set-description myrepo.git "my cool repo" + +usage() { + echo "Usage: set-description " + echo "" + echo "Examples:" + echo " set-description myrepo \"my cool repo\"" + echo " set-description myrepo.git \"my cool repo\"" + exit 1 +} + +if [ "$#" -ne 2 ]; then + echo "Error: expected 2 arguments, got $#" + usage +fi + +PROJECT_NAME="$1" +DESCRIPTION="$2" + +if [[ "$PROJECT_NAME" != *.git ]]; then + PROJECT_NAME="${PROJECT_NAME}.git" +fi + +if [ ! -d "$PROJECT_NAME" ]; then + echo "Error: '$PROJECT_NAME' does not exist" + exit 1 +fi + +echo "$DESCRIPTION" > "${PROJECT_NAME}/description" +echo "description updated: $PROJECT_NAME" + +PUBLIC_FILE="${PROJECT_NAME}/public.conf" +if [ -f "$PUBLIC_FILE" ]; then + REPO_URL=$(cat "$PUBLIC_FILE" | tr -d '\n' | xargs) + REMOTE_HOST="${REPO_URL%%:*}" + REMOTE_PATH="${REPO_URL##*:}" + ssh "$REMOTE_HOST" set-description "$REMOTE_PATH" "$DESCRIPTION" + echo "description updated on remote: $REPO_URL" +fi + +# vim: filetype=bash -- cgit v1.2.3