diff options
| author | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-22 21:41:32 +0300 |
|---|---|---|
| committer | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-22 21:41:32 +0300 |
| commit | 901bd1ab6ba25491f138d3eba9bfa2ed3ac82488 (patch) | |
| tree | 25030576eb8c55913aea1dfd9bd9652f664e0a07 /roles/jails/22_forge/files/git-shell-commands | |
| parent | 3d5cdb0447834fb8460dce7b9a8f4ea1c931a0c0 (diff) | |
Revert to single forge user, improve
Diffstat (limited to 'roles/jails/22_forge/files/git-shell-commands')
7 files changed, 13 insertions, 32 deletions
diff --git a/roles/jails/22_forge/files/git-shell-commands/delete b/roles/jails/22_forge/files/git-shell-commands/delete index 78666ed..1251dec 100644 --- a/roles/jails/22_forge/files/git-shell-commands/delete +++ b/roles/jails/22_forge/files/git-shell-commands/delete @@ -1,4 +1,5 @@ #!/bin/sh +set -e if [ -z "$1" ]; then echo "Usage: delete [REPO_NAME]" exit 1 @@ -7,8 +8,5 @@ if [ ! -d "$1.git" ]; then echo "Repository $1 does not exist" exit 1 fi - -GROUP="r_$(echo "$1" | sed 's/^\.//' | sha1 -q | cut -c1-14)" rm -rf "$1.git" -pw groupdel "$GROUP" 2>/dev/null || true echo "Deleted repository $1" diff --git a/roles/jails/22_forge/files/git-shell-commands/describe b/roles/jails/22_forge/files/git-shell-commands/describe index 43f75db..46451bf 100644 --- a/roles/jails/22_forge/files/git-shell-commands/describe +++ b/roles/jails/22_forge/files/git-shell-commands/describe @@ -1,4 +1,5 @@ #!/bin/sh +set -e if [ "$#" -ne 2 ]; then echo "Usage: describe [REPO_NAME] [DESCRIPTION]" echo "Note: quote the description if it contains spaces" diff --git a/roles/jails/22_forge/files/git-shell-commands/help b/roles/jails/22_forge/files/git-shell-commands/help index 0494ae3..8fcad52 100644 --- a/roles/jails/22_forge/files/git-shell-commands/help +++ b/roles/jails/22_forge/files/git-shell-commands/help @@ -1,4 +1,5 @@ #!/bin/sh +set -e cat <<EOF Available commands: diff --git a/roles/jails/22_forge/files/git-shell-commands/ls b/roles/jails/22_forge/files/git-shell-commands/ls index d72fa9a..7fd2dd4 100644 --- a/roles/jails/22_forge/files/git-shell-commands/ls +++ b/roles/jails/22_forge/files/git-shell-commands/ls @@ -1,11 +1,12 @@ #!/bin/sh -find . -maxdepth 1 -type d -name "*.git" | sort | while read repo; do +for repo in "$HOME"/*.git "$HOME"/.*.git; do + [ -d "$repo" ] || continue name="$(basename "$repo" .git)" desc="$(cat "$repo/description" 2>/dev/null)" - mirror_to="$(git -C "$repo" remote get-url mirror-to 2>/dev/null)" - mirror_from="$(git -C "$repo" remote get-url mirror-from 2>/dev/null)" + mirror_to="$(git -C "$repo" remote get-url mirror-to 2>/dev/null || true)" + mirror_from="$(git -C "$repo" remote get-url mirror-from 2>/dev/null || true)" - printf "%-30s %s\n" "$name" "$desc" + printf "%-30s %s\n" "$name" "${desc:-<no description>}" [ -n "$mirror_to" ] && printf " %-28s -> %s\n" "" "$mirror_to" [ -n "$mirror_from" ] && printf " %-28s <- %s\n" "" "$mirror_from" done diff --git a/roles/jails/22_forge/files/git-shell-commands/mirror b/roles/jails/22_forge/files/git-shell-commands/mirror index 30237af..2a488d3 100644 --- a/roles/jails/22_forge/files/git-shell-commands/mirror +++ b/roles/jails/22_forge/files/git-shell-commands/mirror @@ -1,4 +1,5 @@ #!/bin/sh +set -e # mirror [REPO] to [URL] - set up hourly push mirror # mirror [REPO] from [URL] - set up hourly fetch mirror # mirror [REPO] delete - remove any mirror diff --git a/roles/jails/22_forge/files/git-shell-commands/new b/roles/jails/22_forge/files/git-shell-commands/new index 7fdf61e..87d8e62 100644 --- a/roles/jails/22_forge/files/git-shell-commands/new +++ b/roles/jails/22_forge/files/git-shell-commands/new @@ -1,4 +1,5 @@ #!/bin/sh +set -e if [ -z "$1" ]; then echo "Usage: new [REPO_NAME]" echo "Tip: prefix with '.' to make private (e.g. new .myrepo)" @@ -7,26 +8,16 @@ fi REPO="$1" REPO_PATH="$HOME/$REPO.git" -GROUP="r_$(echo "$REPO" | sed 's/^\.//' | sha1 -q | cut -c1-14)" if [ -d "$REPO_PATH" ]; then echo "Repository $REPO already exists" exit 1 fi -# Create repo group -pw groupadd "$GROUP" 2>/dev/null || true -pw groupmod "$GROUP" -m "$USER" 2>/dev/null || true - -# Init bare repo git init --bare "$REPO_PATH" echo "" > "$REPO_PATH/description" +chown -R git:git "$REPO_PATH" -# Set ownership and permissions -chown -R "$USER:$GROUP" "$REPO_PATH" - -# Public: rwxr-x--- (group can read, others nothing) -# Private (dot-prefix): rwx------ (only owner) if [ "${REPO#.}" = "$REPO" ]; then chmod -R 2755 "$REPO_PATH" else @@ -34,7 +25,7 @@ else fi echo "Created repository $REPO" -echo "Clone: $USER@forge.jan.systems:$REPO.git" +echo "Clone: git@forge.jan.systems:$REPO.git" if [ "${REPO#.}" = "$REPO" ]; then echo "Web: https://forge.jan.systems/$REPO.git" fi diff --git a/roles/jails/22_forge/files/git-shell-commands/rename b/roles/jails/22_forge/files/git-shell-commands/rename index 8586991..be79192 100644 --- a/roles/jails/22_forge/files/git-shell-commands/rename +++ b/roles/jails/22_forge/files/git-shell-commands/rename @@ -1,4 +1,5 @@ #!/bin/sh +set -e if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: rename [OLD_NAME] [NEW_NAME]" exit 1 @@ -11,18 +12,5 @@ if [ -d "$2.git" ]; then echo "Repository $2 already exists" exit 1 fi - -OLD_GROUP="r_$(echo "$1" | sed 's/^\.//' | sha1 -q | cut -c1-14)" -NEW_GROUP="r_$(echo "$2" | sed 's/^\.//' | sha1 -q | cut -c1-14)" - mv "$1.git" "$2.git" - -# Rename group -pw groupmod "$OLD_GROUP" -l "$NEW_GROUP" 2>/dev/null || { - pw groupadd "$NEW_GROUP" 2>/dev/null || true - pw groupmod "$NEW_GROUP" -m "$USER" 2>/dev/null || true - pw groupdel "$OLD_GROUP" 2>/dev/null || true -} - -chown -R "$USER:$NEW_GROUP" "$2.git" echo "Renamed $1 to $2" |
