summaryrefslogtreecommitdiff
path: root/git-shell-commands
diff options
context:
space:
mode:
Diffstat (limited to 'git-shell-commands')
-rwxr-xr-xgit-shell-commands/change-description10
-rwxr-xr-xgit-shell-commands/change-owner13
-rwxr-xr-xgit-shell-commands/create-bare-repo21
-rwxr-xr-xgit-shell-commands/delete-repo16
-rwxr-xr-xgit-shell-commands/fetch-mirrors20
-rwxr-xr-xgit-shell-commands/help12
-rwxr-xr-xgit-shell-commands/hook-install23
-rwxr-xr-xgit-shell-commands/mirror12
-rwxr-xr-xgit-shell-commands/mirrors11
9 files changed, 123 insertions, 15 deletions
diff --git a/git-shell-commands/change-description b/git-shell-commands/change-description
index 437833c..730777c 100755
--- a/git-shell-commands/change-description
+++ b/git-shell-commands/change-description
@@ -1,12 +1,12 @@
#!/bin/sh
-# Allows users to change project description
-# $ ssh git@host change-description repo "description"
+# * change-description
+# Cambia la descripcion del projecto, necesita archivo description en el proyecto
+# ssh git@host change-description repo "description"
-set -E
+set -e
repo=$1; shift
-description="$@"
-echo "${repo}.git/${description}" > description
+test -d ${repo}.git && echo "${@}" > ${repo}.git/description
exit $?
diff --git a/git-shell-commands/change-owner b/git-shell-commands/change-owner
new file mode 100755
index 0000000..4cf90c7
--- /dev/null
+++ b/git-shell-commands/change-owner
@@ -0,0 +1,13 @@
+#!/bin/sh
+# * change-owner
+# Define quiƩn manda
+# ssh git@host change-owner repo "Hacklab"
+
+set -e
+
+repo=$1; shift
+
+test -d "${repo}".git && \
+git config -f "${repo}.git/config" "gitweb.owner" "${@}"
+
+exit $?
diff --git a/git-shell-commands/create-bare-repo b/git-shell-commands/create-bare-repo
index 14a640b..3051c9d 100755
--- a/git-shell-commands/create-bare-repo
+++ b/git-shell-commands/create-bare-repo
@@ -1,16 +1,17 @@
#!/bin/sh
-# Allows users to create repo.git
-# $ ssh git@host create-bare-repo repo1 repo2 ...
+# * create-bare-repo
+# Allows users to create repo.git
+# ssh git@host create-bare-repo repo1 repo2 ...
-set -E
+set -e
-for i in $@; do
-# Cleanup names
- i="`echo "$i" | sed "s/[^a-z0-9\.\-\_]//gi"`"
+for repo in $@; do
+# Cleanup names, allow hidden repos
+ repo="`echo "$repo" | sed -e "s/\.\.//g" -e "s,^/\+,,g" -e "s,[^a-z0-9\./_-],,gi"`"
+ test -d "$repo".git && continue
- if [ -z "$i" ]; then continue; fi
-
- mkdir "$i".git
- pushd "$i".git
+ mkdir -p "$repo".git
+ pushd "$repo".git
git init --bare
+ popd
done
diff --git a/git-shell-commands/delete-repo b/git-shell-commands/delete-repo
new file mode 100755
index 0000000..4ca644e
--- /dev/null
+++ b/git-shell-commands/delete-repo
@@ -0,0 +1,16 @@
+#!/bin/sh
+# * delete-repo
+# Allows users to delete repositories permanently
+# ssh git@host delete-repo repo1 repo2 ...
+
+set -e
+
+for repo in $@; do
+# Remove leading slashes and dots and perform cleanup
+ repo="`echo "$repo" | sed -e "s/\.\.//g" -e "s,^/\+,,g" -e "s,[^a-z0-9\./_-],,gi"`"
+ test ! -d "$repo".git && 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..a9442ba
--- /dev/null
+++ b/git-shell-commands/fetch-mirrors
@@ -0,0 +1,20 @@
+#!/bin/sh
+# * fetch-mirrors
+# Actualiza el `mirrors` (espejos) creados con `mirror`
+# ssh git@host fetch-mirrors
+
+set -e
+
+# Find all mirrors
+~/git-shell-commands/mirrors | \
+ while read _mirror; do
+
+ pushd "$_mirror" >/dev/null
+
+ git remote update
+
+ popd >/dev/null
+
+done
+
+exit $?
diff --git a/git-shell-commands/help b/git-shell-commands/help
new file mode 100755
index 0000000..e707df8
--- /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 three lines from every git-shell-command
+for c in `dirname $0`/*; do
+ head -q -n4 $c | tail -n3 | sed "s/^..//"
+ echo
+done
diff --git a/git-shell-commands/hook-install b/git-shell-commands/hook-install
new file mode 100755
index 0000000..08a0340
--- /dev/null
+++ b/git-shell-commands/hook-install
@@ -0,0 +1,23 @@
+#!/bin/sh
+# * hook-install
+# Instala un hook en un repo
+# ssh git@host hook-install hook script repo [alt-dir]
+
+set -e
+
+hook="${1}"
+script="${HOME}/.ssh/git-hooks/${2}"
+repo="${HOME}/${3}"
+clone="${4:-${repo}}"
+
+# Tests
+test -f "${repo}/HEAD"
+test -f "${clone}/.git/HEAD"
+
+# Installs the generic hook that runs scripts
+test -f "${repo}/hooks/${hook}" || ln -s "${HOME}/.ssh/git-hooks/generic" "${repo}/hooks/${hook}"
+
+# Install the hook on the repo
+git config -f "${repo}/config" --add "hacking.hooks.${hook}.${2}" "${clone}"
+
+exit $?
diff --git a/git-shell-commands/mirror b/git-shell-commands/mirror
new file mode 100755
index 0000000..212687e
--- /dev/null
+++ b/git-shell-commands/mirror
@@ -0,0 +1,12 @@
+#!/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
+
+exit $?
diff --git a/git-shell-commands/mirrors b/git-shell-commands/mirrors
new file mode 100755
index 0000000..d1301a8
--- /dev/null
+++ b/git-shell-commands/mirrors
@@ -0,0 +1,11 @@
+#!/bin/sh
+# * mirrors
+# Muestra todos los repositorios espejos (mirror)
+# ssh git@host mirrors
+
+set -e
+
+# Find all mirrors
+find *.git -maxdepth 1 -iname config -print0 | \
+ xargs -0 grep -l 'mirror = true' | \
+ sed 's,/config$,,'