aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/22_forge/files/git-shell-commands
diff options
context:
space:
mode:
Diffstat (limited to 'roles/jails/22_forge/files/git-shell-commands')
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/delete11
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/describe11
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/help11
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/ls4
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/new12
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/rename15
6 files changed, 64 insertions, 0 deletions
diff --git a/roles/jails/22_forge/files/git-shell-commands/delete b/roles/jails/22_forge/files/git-shell-commands/delete
new file mode 100644
index 0000000..1c1ce0d
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/delete
@@ -0,0 +1,11 @@
+#!/bin/sh
+if [ -z "$1" ]; then
+ echo "Usage: delete [REPO_NAME]"
+ exit 1
+fi
+if [ ! -d "$1.git" ]; then
+ echo "Repository $1 does not exist"
+ exit 1
+fi
+rm -rf "$1.git"
+echo "Deleted repository $1"
diff --git a/roles/jails/22_forge/files/git-shell-commands/describe b/roles/jails/22_forge/files/git-shell-commands/describe
new file mode 100644
index 0000000..b5b0451
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/describe
@@ -0,0 +1,11 @@
+#!/bin/sh
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "Usage: describe [REPO_NAME] [DESCRIPTION]"
+ exit 1
+fi
+if [ ! -d "$1.git" ]; then
+ echo "Repository $1 does not exist"
+ exit 1
+fi
+echo "$2" > "$1.git/description"
+echo "Updated description for $1"
diff --git a/roles/jails/22_forge/files/git-shell-commands/help b/roles/jails/22_forge/files/git-shell-commands/help
new file mode 100644
index 0000000..fd0690d
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/help
@@ -0,0 +1,11 @@
+#!/bin/sh
+cat <<EOF
+Available commands:
+
+ new [REPO_NAME] - create a new bare repository
+ ls - list repositories
+ describe [REPO_NAME] [DESCRIPTION] - set repository description
+ rename [OLD_NAME] [NEW_NAME] - rename a repository
+ delete [REPO_NAME] - delete a repository
+
+EOF
diff --git a/roles/jails/22_forge/files/git-shell-commands/ls b/roles/jails/22_forge/files/git-shell-commands/ls
new file mode 100644
index 0000000..ef5d3e5
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/ls
@@ -0,0 +1,4 @@
+#!/bin/sh
+find . -maxdepth 1 -type d -name "*.git" | while read repo; do
+ basename "$repo" .git
+done | sort
diff --git a/roles/jails/22_forge/files/git-shell-commands/new b/roles/jails/22_forge/files/git-shell-commands/new
new file mode 100644
index 0000000..ba67bc4
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/new
@@ -0,0 +1,12 @@
+#!/bin/sh
+if [ -z "$1" ]; then
+ echo "Usage: new [REPO_NAME]"
+ exit 1
+fi
+if [ -d "$1.git" ]; then
+ echo "Repository $1 already exists"
+ exit 1
+fi
+git init --bare "$1.git"
+echo "$1" > "$1.git/description"
+echo "Created repository $1"
diff --git a/roles/jails/22_forge/files/git-shell-commands/rename b/roles/jails/22_forge/files/git-shell-commands/rename
new file mode 100644
index 0000000..2d1f73e
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/rename
@@ -0,0 +1,15 @@
+#!/bin/sh
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "Usage: rename [OLD_NAME] [NEW_NAME]"
+ exit 1
+fi
+if [ ! -d "$1.git" ]; then
+ echo "Repository $1 does not exist"
+ exit 1
+fi
+if [ -d "$2.git" ]; then
+ echo "Repository $2 already exists"
+ exit 1
+fi
+mv "$1.git" "$2.git"
+echo "Renamed $1 to $2"