diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-01-06 18:32:42 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-01-06 18:32:42 +0100 |
commit | fb4640e4bccb0b6dcd6bc821ec8789c0e53d3cb6 (patch) | |
tree | cb31711fc2999c315f95972a81ac2bff34c50e72 /.local | |
parent | f39fb985fbbc01d7ba6c111d5dec26d4c5f1a657 (diff) | |
parent | d2fd4236ae913803862568b06c549d77e378b9b3 (diff) |
Merge branch 'master' of 10.24.100.1:.local/git/dotfiles
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/git-mkbare | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.local/bin/git-mkbare b/.local/bin/git-mkbare new file mode 100755 index 0000000..bd9615c --- /dev/null +++ b/.local/bin/git-mkbare @@ -0,0 +1,64 @@ +#! /usr/bin/env sh + +main() +{ + # Handle opts + opts "$@" + shift "$OPTS" + unset OPTS + + # Show help + [ "$OPT_HELP_ONLY" ] && usage && exit 0 + + location=$(readlink -f "${1:-$PWD}") + + # Prompt for location + printf "%s: [%s] " "Path" "$location" + read -r input + [ -z "$input" ] || location=$(readlink -f "$input") + unset input + + # Prompt for description + printf "%s: " "Description" + read -r description + + # Create the bare git repository + mkdir -p "$location" + cd -- "$location" + git --bare init + + # Update the description, if given + printf "%s\n" "$description" > "$location/description" +} + +opts() +{ + OPTS=0 + + while getopts ":h" opt + do + case "$opt" in + h) OPT_HELP_ONLY=1 ;; + *) + printf "Invalid option passed: %s\n" "$OPTARG" >&2 + ;; + esac + done + + unset opt +} + +usage() +{ + cat <<EOF +Usage: + $(basename "$0") -h + +Create a bare git repository at a target location. + +Options: + -h Show this help text and exit. +EOF +} + +main "$@" |