aboutsummaryrefslogtreecommitdiff
path: root/cgit/ssh/git-shell-commands/fork
diff options
context:
space:
mode:
Diffstat (limited to 'cgit/ssh/git-shell-commands/fork')
-rwxr-xr-xcgit/ssh/git-shell-commands/fork32
1 files changed, 32 insertions, 0 deletions
diff --git a/cgit/ssh/git-shell-commands/fork b/cgit/ssh/git-shell-commands/fork
new file mode 100755
index 0000000..52803d3
--- /dev/null
+++ b/cgit/ssh/git-shell-commands/fork
@@ -0,0 +1,32 @@
+#!/usr/bin/env sh
+
+set -eu
+
+remote_host="git.ediblemonad.dev"
+owner_info="Akshay Nair <phenax5@gmail.com>"
+
+if [ $# -lt 2 ]; then
+ echo "Usage: fork <name> <url>" 1>&2
+ exit 1
+fi
+
+repo_name="$1"; shift 1;
+[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1
+
+remote_repo_url="$1"; shift 1;
+[ -z "$remote_repo_url" ] && echo "Error: empty repo url" 1>&2 && exit 1
+
+repo_dir="/git/${repo_name}.git"
+
+if [ -d "$repo_dir" ]; then
+ echo "Error: $repo_name already exists" 1>&2
+ exit 1;
+fi
+
+git clone --bare "$remote_repo_url" "$repo_dir"
+
+cd "$repo_dir"
+echo "Fork of $remote_repo_url" > description
+echo "$owner_info" > owner_info
+
+echo "git@${remote_host}:${repo_dir}"