diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-02-12 15:38:15 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-02-12 15:38:15 +0100 |
commit | 499984f63fe2dece153c9f717087ca85e2628158 (patch) | |
tree | 73a7c9f89dda56a82ca151421aa463f6700965b9 /.local/bin | |
parent | b8520be090a5abe06e53aba970baccef1d1987a7 (diff) |
Update git-mkbare script
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/git-mkbare | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/.local/bin/git-mkbare b/.local/bin/git-mkbare index bd9615c..973ebae 100755 --- a/.local/bin/git-mkbare +++ b/.local/bin/git-mkbare @@ -1,5 +1,8 @@ #! /usr/bin/env sh +readonly CGIT_INDEX="$HOME/.local/srv/cgit" +readonly GIT_INDEX="$HOME/.local/git" + main() { # Handle opts @@ -10,6 +13,8 @@ main() # Show help [ "$OPT_HELP_ONLY" ] && usage && exit 0 + cd -- "$GIT_INDEX" + location=$(readlink -f "${1:-$PWD}") # Prompt for location @@ -22,6 +27,23 @@ main() printf "%s: " "Description" read -r description + # Prompt for linking into cgit index + if [ -d "$CGIT_INDEX" ] + then + while : + do + printf "%s: [%s] " "Link in cgit?" "Y/n" + read -r input + + case "$input" in + Y|y|'') cgit_link=1; break;; + N|n) break;; + esac + done + + unset input + fi + # Create the bare git repository mkdir -p "$location" cd -- "$location" @@ -29,6 +51,13 @@ main() # Update the description, if given printf "%s\n" "$description" > "$location/description" + + # Link into cgit index + if [ -n "$cgit_link" ] + then + mkdir -p "$CGIT_INDEX/$(dirname "${location#$GIT_INDEX}")" + ln -s "$location" "$CGIT_INDEX/${location#$GIT_INDEX}" + fi } opts() |