summaryrefslogtreecommitdiff
path: root/misc/git-shell-commands
diff options
context:
space:
mode:
Diffstat (limited to 'misc/git-shell-commands')
-rwxr-xr-xmisc/git-shell-commands/change-description19
-rwxr-xr-xmisc/git-shell-commands/change-owner19
-rwxr-xr-xmisc/git-shell-commands/create-bare-repo18
-rwxr-xr-xmisc/git-shell-commands/delete-repo17
-rwxr-xr-xmisc/git-shell-commands/fetch-mirrors13
-rwxr-xr-xmisc/git-shell-commands/help12
-rwxr-xr-xmisc/git-shell-commands/hook-install28
-rwxr-xr-xmisc/git-shell-commands/mirror10
-rwxr-xr-xmisc/git-shell-commands/mirrors9
9 files changed, 145 insertions, 0 deletions
diff --git a/misc/git-shell-commands/change-description b/misc/git-shell-commands/change-description
new file mode 100755
index 0000000..60db0ac
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/change-owner b/misc/git-shell-commands/change-owner
new file mode 100755
index 0000000..6b6f353
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/create-bare-repo b/misc/git-shell-commands/create-bare-repo
new file mode 100755
index 0000000..b4d2d5f
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/delete-repo b/misc/git-shell-commands/delete-repo
new file mode 100755
index 0000000..5ef94b1
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/fetch-mirrors b/misc/git-shell-commands/fetch-mirrors
new file mode 100755
index 0000000..15bf9c4
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/help b/misc/git-shell-commands/help
new file mode 100755
index 0000000..f1d116b
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/hook-install b/misc/git-shell-commands/hook-install
new file mode 100755
index 0000000..b38836a
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/mirror b/misc/git-shell-commands/mirror
new file mode 100755
index 0000000..8282e9b
--- /dev/null
+++ b/misc/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/misc/git-shell-commands/mirrors b/misc/git-shell-commands/mirrors
new file mode 100755
index 0000000..436564f
--- /dev/null
+++ b/misc/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$,,'