aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/.local/bin/git-create-public30
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/.local/bin/git-create-public b/bin/.local/bin/git-create-public
new file mode 100755
index 0000000..2c81d0a
--- /dev/null
+++ b/bin/.local/bin/git-create-public
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+
+server='hwebs@marta'
+base='/usr/local/git/public'
+name=${1:?Usage: git-create-public name [description]}
+description=${2-}
+
+if [ "$#" -lt 2 ]; then
+ printf 'Description (blank to skip): ' >&2
+ IFS= read -r description || true
+fi
+
+# Quote values for the remote shell, including any embedded single quotes.
+quote() {
+ printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"
+}
+
+{
+ printf 'repo=%s\n' "$(quote "$base/${name%.git}.git")"
+ printf 'description=%s\n' "$(quote "$description")"
+ printf '%s\n' '
+set -e
+mkdir "$repo"
+git init --bare "$repo"
+if [ -n "$description" ]; then
+ git --git-dir="$repo" config --local cgit.desc "$description"
+fi
+'
+} | ssh "$server" 'sh -s'