diff options
| author | Trey Bastian <hello@treybastian.com> | 2026-04-08 17:09:07 +0100 |
|---|---|---|
| committer | Trey Bastian <hello@treybastian.com> | 2026-04-08 17:09:07 +0100 |
| commit | b0684c87580926fa00c221afcc4461ca812390a0 (patch) | |
| tree | 5a0ab4dcdf6af0ee9793964dfde3f96c7eb121b9 /git-shell-commands/make-public | |
| parent | 9cac75c2f8626f7f3208aad61857b9d9f0732c75 (diff) | |
added make-public command to make a private repo public
Diffstat (limited to 'git-shell-commands/make-public')
| -rwxr-xr-x | git-shell-commands/make-public | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/git-shell-commands/make-public b/git-shell-commands/make-public new file mode 100755 index 0000000..d57ccbf --- /dev/null +++ b/git-shell-commands/make-public @@ -0,0 +1,49 @@ +#!/bin/bash +set -euo pipefail +# this script makes an existing private repo public by creating a public.conf +# +# USAGE: +# ssh git@<host> make-public <name> +# +# EXAMPLES: +# ssh git@treybastian.com make-public myrepo +# ssh git@treybastian.com make-public myrepo.git + +REMOTE_BASE_URL="git@treybastian.com:repos" + +usage() { + echo "Usage: make-public <name>" + echo "" + echo "Examples:" + echo " make-public myrepo" + echo " make-public myrepo.git" + exit 1 +} + +if [ "$#" -ne 1 ]; then + echo "Error: expected 1 argument, got $#" + usage +fi + +PROJECT_NAME="$1" + +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 + +if [ -f "${PROJECT_NAME}/public.conf" ]; then + echo "Error: '$PROJECT_NAME' is already public" + exit 1 +fi + +echo "${REMOTE_BASE_URL}/${PROJECT_NAME}" > "${PROJECT_NAME}/public.conf" +ssh git@treybastian.com new-repo "repos/${PROJECT_NAME}" + +echo "repo is now public: ${REMOTE_BASE_URL}/${PROJECT_NAME}" + +# vim: filetype=bash |
