From 97c6c6b7823d9d713f836f967fd10cc3facc36ac Mon Sep 17 00:00:00 2001 From: Trey Bastian Date: Wed, 8 Apr 2026 14:36:22 +0100 Subject: updated scripts to slightly new workflow --- git-shell-commands/new-project | 33 +++++++++++++++++++++++++++++++++ git-shell-commands/new-repo | 24 +++++++----------------- 2 files changed, 40 insertions(+), 17 deletions(-) create mode 100755 git-shell-commands/new-project (limited to 'git-shell-commands') diff --git a/git-shell-commands/new-project b/git-shell-commands/new-project new file mode 100755 index 0000000..c9804bf --- /dev/null +++ b/git-shell-commands/new-project @@ -0,0 +1,33 @@ +#!/bin/bash +# this script allows the creation of projects over ssh on git server +# public repos will get a public.conf containing the remote +# private repos will just exist on the server +# +# USAGE: +# ssh git@ new-project +# - follow the prompts + +REMOTE_BASE_URL = "git@treybastian.com:repos/" +echo "oh look you are starting a project you won't finish again." +echo "What is your projects name?" +read PROJECT_NAME +if [[ $PROJECT_NAME!=*.git ]]; then + PROJECT_NAME="${PROJECT_NAME}.git" +fi +read -p "Is this public?" -n 1 -r +echo + +git --bare init "${PROJECT_NAME}" + +if [[ $REPLY =~ ^[Yy]$ ]]; then + touch "${PROJECT_NAME}/public.conf" + echo "${REMOTE_BASE_URL}/${PROJECT_NAME}" >> "${PROJECT_NAME}/public.conf" + ssh git@treybastian.com new-repo "repos/${PROJECT_NAME}" +fi + +echo "git url: ${USER}@${HOSTNAME}:${PROJECT_NAME}" +if [[ $REMOTE_URL ]]; then + echo "public repo: ${REMOTE_BASE_URL}/${PROJECT_NAME}" +fi + +#vim: filetype=bash diff --git a/git-shell-commands/new-repo b/git-shell-commands/new-repo index 52bd69f..f6b2dc8 100755 --- a/git-shell-commands/new-repo +++ b/git-shell-commands/new-repo @@ -1,29 +1,19 @@ #!/bin/bash # this script allows the creation of new repos over ssh on git server -# public repos will get a knot.conf containing the remote -# private repos will just exist on the server # USAGE: -# ssh git@ new-repo +# ssh git@ new-repo # - follow the prompts -echo "oh look you are starting a project you won't finish again." -echo "What is your projects name?" -read PROJECT_NAME +$PROJECT_NAME = $1 +if [[ -z "$1" ]]; then + echo "project name cannot be empty" + exit 1 +fi if [[ $PROJECT_NAME!=*.git ]]; then PROJECT_NAME="${PROJECT_NAME}.git" fi -echo "What's the mirror repo remote url?(leave blank if private)" -read REMOTE_URL git --bare init "${PROJECT_NAME}" -if [[ $REMOTE_URL ]]; then - touch "${PROJECT_NAME}/knot.conf" - echo "${REMOTE_URL}" >> "${PROJECT_NAME}/knot.conf" -fi - -echo "git url: ${USER}@${HOSTNAME}:${PROJECT_NAME}" -if [[ $REMOTE_URL ]]; then - echo "public repo: ${REMOTE_URL}" -fi +echo "project created" #vim: filetype=bash -- cgit v1.2.3