summaryrefslogtreecommitdiff
path: root/git-shell-commands
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-07-07 18:31:06 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-07-07 18:31:06 -0400
commitf985decc7edecd2376a4d08cdc29bbf42f18da12 (patch)
treef7e8f1e2a49b8152fe33b648daa85fba04fb8181 /git-shell-commands
parent70f3940aa125991d1a565b263b145ee8a63a23ad (diff)
mv {misc/,}git-shell-commands ; remove everything else
Diffstat (limited to 'git-shell-commands')
-rwxr-xr-xgit-shell-commands/change-description19
-rwxr-xr-xgit-shell-commands/change-owner19
-rwxr-xr-xgit-shell-commands/create-bare-repo18
-rwxr-xr-xgit-shell-commands/delete-repo17
-rwxr-xr-xgit-shell-commands/fetch-mirrors13
-rwxr-xr-xgit-shell-commands/help12
-rwxr-xr-xgit-shell-commands/hook-install28
-rwxr-xr-xgit-shell-commands/mirror10
-rwxr-xr-xgit-shell-commands/mirrors9
9 files changed, 145 insertions, 0 deletions
diff --git a/git-shell-commands/change-description b/git-shell-commands/change-description
new file mode 100755
index 0000000..60db0ac
--- /dev/null
+++ b/git-shell-commands/change-description
@@ -0,0 +1,19 @@
+#!/bin/bash
+# * change-description
+# Cambia la descripcion del projecto, necesita archivo description en el proyecto
+# ssh git@host change-description repo "description"
+
+set -e
+
+repo=$1; shift
+
+repo="$(sed -r 's,^/*,,' <<<"$repo")"
+_repo="$(sed -r -e '/(^|\/)\.\.($|\/)/d' -e "s,[^A-Za-z0-9\./_~-],,g" <<<"$repo")"
+test "$repo" = "$_repo" || { printf 'Illegal name: %s\n' "${repo}"; exit 1; }
+
+if test -d "$repo".git; then
+ echo "${*}" > "${repo}".git/description
+else
+ printf 'Does not exist: %s\n' "${repo}"
+ exit 1
+fi
diff --git a/git-shell-commands/change-owner b/git-shell-commands/change-owner
new file mode 100755
index 0000000..6b6f353
--- /dev/null
+++ b/git-shell-commands/change-owner
@@ -0,0 +1,19 @@
+#!/bin/bash
+# * change-owner
+# Define quiƩn manda
+# ssh git@host change-owner repo "Hacklab"
+
+set -e
+
+repo=$1; shift
+
+repo="$(sed -r 's,^/*,,' <<<"$repo")"
+_repo="$(sed -r -e '/(^|\/)\.\.($|\/)/d' -e "s,[^A-Za-z0-9\./_~-],,g" <<<"$repo")"
+test "$repo" = "$_repo" || { printf 'Illegal name: %s\n' "${repo}"; exit 1; }
+
+if test -d "${repo}".git; then
+ git config -f "${repo}.git/config" "gitweb.owner" "${*}"
+else
+ printf 'Does not exist: %s\n' "${repo}"
+ exit 1
+fi
diff --git a/git-shell-commands/create-bare-repo b/git-shell-commands/create-bare-repo
new file mode 100755
index 0000000..b4d2d5f
--- /dev/null
+++ b/git-shell-commands/create-bare-repo
@@ -0,0 +1,18 @@
+#!/bin/bash
+# * create-bare-repo
+# Allows users to create repo.git
+# ssh git@host create-bare-repo repo1 repo2 ...
+
+set -e
+
+for repo in "$@"; do
+ repo="$(sed -r 's,^/*,,' <<<"$repo")"
+ _repo="$(sed -r -e '/(^|\/)\.\.($|\/)/d' -e "s,[^A-Za-z0-9\./_~-],,g" <<<"$repo")"
+ test "$repo" != "$_repo" && { printf 'Illegal name: %s\n' "${repo}"; continue; }
+ test -d "$repo".git && { printf 'Already exists: %s\n' "${repo}"; continue; }
+
+ mkdir -p -- "$repo".git
+ pushd "$repo".git >/dev/null
+ git init --bare
+ popd >/dev/null
+done
diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo
new file mode 100755
index 0000000..5ef94b1
--- /dev/null
+++ b/git-shell-commands/delete-repo
@@ -0,0 +1,17 @@
+#!/bin/bash
+# * delete-repo
+# Allows users to delete repositories permanently
+# ssh git@host delete-repo repo1 repo2 ...
+
+set -e
+
+for repo in "$@"; do
+ repo="$(sed -r 's,^/*,,' <<<"$repo")"
+ _repo="$(sed -r -e '/(^|\/)\.\.($|\/)/d' -e "s,[^A-Za-z0-9\./_~-],,g" <<<"$repo")"
+ test "$repo" != "$_repo" && { printf 'Illegal name: %s\n' "${repo}"; continue; }
+ test ! -d "$repo".git && { printf 'Does not exist: %s\n' "${repo}"; continue; }
+
+ echo "Removing ${repo}.git"
+ # lo and behold absolute horror
+ rm -rf -- "$repo".git
+done
diff --git a/git-shell-commands/fetch-mirrors b/git-shell-commands/fetch-mirrors
new file mode 100755
index 0000000..15bf9c4
--- /dev/null
+++ b/git-shell-commands/fetch-mirrors
@@ -0,0 +1,13 @@
+#!/bin/sh
+# * fetch-mirrors
+# Actualiza el `mirrors` (espejos) creados con `mirror`
+# ssh git@host fetch-mirrors
+
+set -e
+
+# Find all mirrors
+"$(dirname "$0")"/mirrors | while read -r mirror; do
+ pushd "$mirror" >/dev/null
+ git remote update
+ popd >/dev/null
+done
diff --git a/git-shell-commands/help b/git-shell-commands/help
new file mode 100755
index 0000000..f1d116b
--- /dev/null
+++ b/git-shell-commands/help
@@ -0,0 +1,12 @@
+#!/bin/sh
+# * help
+# Obtiene los comando habilitados
+# ssh git@host help
+
+set -e
+
+# Gets the initial comment after the shebeng from every git-shell-command
+for c in "$(dirname "$0")"/*; do
+ sed -rn '2,/^[^#]/s/^# ?//p' "$c"
+ echo
+done
diff --git a/git-shell-commands/hook-install b/git-shell-commands/hook-install
new file mode 100755
index 0000000..b38836a
--- /dev/null
+++ b/git-shell-commands/hook-install
@@ -0,0 +1,28 @@
+#!/bin/sh
+# * hook-install
+# Instala un hook en un repo
+# ssh git@host hook-install hook script repo [alt-dir]
+
+set -e
+
+exit 1 # I don't trust this script
+
+hook="${1}"
+script="${HOME}/.ssh/git-hooks/${2}"
+repo="${3}"
+clone="${4:-${repo}}"
+
+repo="$(sed -r 's,^/*,,' <<<"$repo")"
+_repo="$(sed -r -e '/(^|\/)\.\.($|\/)/d' -e "s,[^A-Za-z0-9\./_~-],,g" <<<"$repo")"
+test "$repo" = "$_repo" || { printf 'Illegal name: %s\n' "${repo}"; exit 1; }
+test -d "$repo".git || { printf 'Does not exist: %s\n' "${repo}"; exit 1; }
+
+# Tests
+test -f "${repo}.git/HEAD"
+test -f "${clone}/.git/HEAD"
+
+# Installs the generic hook that runs scripts
+test -f "${repo}.git/hooks/${hook}" || ln -s "${HOME}/.ssh/git-hooks/generic" "${repo}.git/hooks/${hook}"
+
+# Install the hook on the repo
+git config -f "${repo}.git/config" --add "hacking.hooks.${hook}.${2}" "${clone}"
diff --git a/git-shell-commands/mirror b/git-shell-commands/mirror
new file mode 100755
index 0000000..8282e9b
--- /dev/null
+++ b/git-shell-commands/mirror
@@ -0,0 +1,10 @@
+#!/bin/sh
+# * mirror
+# Espeja un repositorio
+# ssh git@host mirror git://url/repo.git
+
+set -E
+
+for _m in "$@"; do
+ git clone --mirror "$_m"
+done
diff --git a/git-shell-commands/mirrors b/git-shell-commands/mirrors
new file mode 100755
index 0000000..436564f
--- /dev/null
+++ b/git-shell-commands/mirrors
@@ -0,0 +1,9 @@
+#!/bin/sh
+# * mirrors
+# Muestra todos los repositorios espejos (mirror)
+# ssh git@host mirrors
+
+set -e
+
+# Find all mirrors
+find $(find * -name '*.git' -type d) -maxdepth 1 -name config -exec grep -l 'mirror\s*=\s*true' {} + | sed 's,/config$,,'