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/new-repo | |
| parent | 9cac75c2f8626f7f3208aad61857b9d9f0732c75 (diff) | |
added make-public command to make a private repo public
Diffstat (limited to 'git-shell-commands/new-repo')
| -rwxr-xr-x | git-shell-commands/new-repo | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/git-shell-commands/new-repo b/git-shell-commands/new-repo index e85c226..c2c454a 100755 --- a/git-shell-commands/new-repo +++ b/git-shell-commands/new-repo @@ -1,19 +1,42 @@ #!/bin/bash -# this script allows the creation of new repos over ssh on git server +set -euo pipefail +# this script creates a bare git repository on the git server +# # USAGE: -# ssh git@<host> new-repo <project name> -# - follow the prompts +# ssh git@<host> new-repo <name> +# +# EXAMPLES: +# ssh git@treybastian.com new-repo myrepo +# ssh git@treybastian.com new-repo myrepo.git -PROJECT_NAME="$1" -if [[ -z "$1" ]]; then - echo "project name cannot be empty" +usage() { + echo "Usage: new-repo <name>" + echo "" + echo "Examples:" + echo " new-repo myrepo" + echo " new-repo myrepo.git" exit 1 +} + +if [ "$#" -ne 1 ]; then + echo "Error: expected 1 argument, got $#" + usage fi -if [[ $PROJECT_NAME != *.git ]]; then + +PROJECT_NAME="$1" + +if [[ "$PROJECT_NAME" != *.git ]]; then PROJECT_NAME="${PROJECT_NAME}.git" fi -git --bare init "${PROJECT_NAME}" +if [ -d "$PROJECT_NAME" ]; then + echo "Error: '$PROJECT_NAME' already exists" + exit 1 +fi + +git --bare init "$PROJECT_NAME" + +echo "repo created: $PROJECT_NAME" +echo "git url: ${USER}@${HOSTNAME}:${PROJECT_NAME}" -echo "project created" -#vim: filetype=bash +# vim: filetype=bash |
