Summary Files Commits Branches @commit @diff @stats
path: root / scripts / public
diff options
context:
space:
mode:
1 files changed, 33 insertions, 0 deletions
-rwxr-xr-xscripts/public33
diff --git a/scripts/public b/scripts/public
new file mode 100755
index 0000000..155a81e
--- /dev/null
+++ b/scripts/public
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Not a repository!'
+ exit 1
+fi
+
+set "${1##/}"
+
+# If repo is in file
+if echo -e "?^$1\$?" | ed -s /public_repos >/dev/null 2>&1
+then
+ echo "Already public!"
+# If repo root dir is in file
+elif echo -e "?^${1%%/*}?" | ed -s /public_repos >/dev/null 2>&1
+then
+ echo -e "?^${1%%/*}?a\n$1\n.\nw" | ed -s /public_repos
+ echo "'$1' is now public!"
+# Repo and repo root dir are not anywhere in file
+else
+ echo -e "\$a\n$1\n.\nw" | ed -s /public_repos
+ echo "'$1' is now public!"
+fi
+
+echo "https://git.syndamia.com/$1"