aboutsummaryrefslogtreecommitdiffstats
path: root/roles/git/files/git-shell-commands/make-public
diff options
context:
space:
mode:
Diffstat (limited to 'roles/git/files/git-shell-commands/make-public')
-rw-r--r--roles/git/files/git-shell-commands/make-public37
1 files changed, 37 insertions, 0 deletions
diff --git a/roles/git/files/git-shell-commands/make-public b/roles/git/files/git-shell-commands/make-public
new file mode 100644
index 0000000..f1dfb1d
--- /dev/null
+++ b/roles/git/files/git-shell-commands/make-public
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (c) 2017 Aaron LI <aly@aaronly.me>
+# MIT License
+#
+# Make an existing Git repository public by linking it into
+# `repos.public`, which is exported via `cgit`.
+#
+# 2017-06-19
+#
+
+. ${HOME}/vars.conf
+
+if [ $# -ne 1 ]; then
+ echo "usage: make-public <repository.git>"
+ exit 1
+fi
+
+if [ ! -e "${PUBLIC}" ]; then
+ echo "ERROR: public directory '${PUBLIC}' not exists!"
+ exit 1
+fi
+
+project="${1%.[gG][iI][tT]}.git"
+
+if [ ! -d "${project}" ]; then
+ echo "ERROR: repository '${project}' not exists!"
+ exit 3
+elif [ -L "${PUBLIC}/${project}" ]; then
+ echo "Repository '${project}' already made public."
+ exit 0
+else
+ ln -sv ../${project} ${PUBLIC}/${project}
+ echo "Made repository '${project}' public."
+ exit 0
+fi
+