From 203a80a56d85107973f99a770826f70aac18878e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 5 Sep 2012 13:40:25 -0300 Subject: Use git user home --- git-hooks/post-receive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-hooks') diff --git a/git-hooks/post-receive b/git-hooks/post-receive index 671dd4e..6164d81 100755 --- a/git-hooks/post-receive +++ b/git-hooks/post-receive @@ -8,7 +8,7 @@ set -E # the ssh dir -ssh_dir=/srv/git/.ssh +ssh_dir=${HOME}/.ssh # pull this repo git --git-dir ${ssh_dir}/.git \ -- cgit v1.2.3-2-g168b From 0de6455d6b8b3b64caf5c4ab96b4166b02cf6655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 9 Sep 2012 17:20:03 -0300 Subject: Make it clearer --- git-hooks/post-receive | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-hooks') diff --git a/git-hooks/post-receive b/git-hooks/post-receive index 6164d81..b78c54d 100755 --- a/git-hooks/post-receive +++ b/git-hooks/post-receive @@ -5,7 +5,7 @@ # cp .ssh/git-hooks/post-receive hackers.git/hooks/ # fail on any error -set -E +set -e # the ssh dir ssh_dir=${HOME}/.ssh @@ -15,7 +15,7 @@ git --git-dir ${ssh_dir}/.git \ --work-tree ${ssh_dir} \ pull origin master -# secure the files +# secure the files (sshd will refuse connections otherwise) chmod 600 ${ssh_dir}/authorized_keys chmod 700 ${ssh_dir} -- cgit v1.2.3-2-g168b From 3f1168d2b0788e3fc9c5923fc9dfbaafe06f8c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Sun, 11 Nov 2012 21:38:26 -0300 Subject: Appropiately call the update hook --- git-hooks/hackers-update | 22 ++++++++++++++++++++++ git-hooks/post-receive | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) create mode 100755 git-hooks/hackers-update delete mode 100755 git-hooks/post-receive (limited to 'git-hooks') diff --git a/git-hooks/hackers-update b/git-hooks/hackers-update new file mode 100755 index 0000000..b78c54d --- /dev/null +++ b/git-hooks/hackers-update @@ -0,0 +1,22 @@ +#!/bin/bash +# post-receive hook, updates /srv/git/.ssh after pushing to this repo +# install: +# git clone hackers.git .ssh +# cp .ssh/git-hooks/post-receive hackers.git/hooks/ + +# fail on any error +set -e + +# the ssh dir +ssh_dir=${HOME}/.ssh + +# pull this repo +git --git-dir ${ssh_dir}/.git \ + --work-tree ${ssh_dir} \ + pull origin master + +# secure the files (sshd will refuse connections otherwise) +chmod 600 ${ssh_dir}/authorized_keys +chmod 700 ${ssh_dir} + +exit $? diff --git a/git-hooks/post-receive b/git-hooks/post-receive deleted file mode 100755 index b78c54d..0000000 --- a/git-hooks/post-receive +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# post-receive hook, updates /srv/git/.ssh after pushing to this repo -# install: -# git clone hackers.git .ssh -# cp .ssh/git-hooks/post-receive hackers.git/hooks/ - -# fail on any error -set -e - -# the ssh dir -ssh_dir=${HOME}/.ssh - -# pull this repo -git --git-dir ${ssh_dir}/.git \ - --work-tree ${ssh_dir} \ - pull origin master - -# secure the files (sshd will refuse connections otherwise) -chmod 600 ${ssh_dir}/authorized_keys -chmod 700 ${ssh_dir} - -exit $? -- cgit v1.2.3-2-g168b From 2f20803b079f39bc97e4b64a4c78aa58e22a8217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 17 Apr 2013 16:33:18 -0300 Subject: Support for installing hooks --- git-hooks/auto-deploy | 16 ++++++++++++++++ git-hooks/generic | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 git-hooks/auto-deploy create mode 100755 git-hooks/generic (limited to 'git-hooks') diff --git a/git-hooks/auto-deploy b/git-hooks/auto-deploy new file mode 100755 index 0000000..0480756 --- /dev/null +++ b/git-hooks/auto-deploy @@ -0,0 +1,16 @@ +#!/bin/bash +# auto-deploy +# Usage: auto-deploy /srv/http/repo + +# fail on any error +set -e + +# Can we write on the clone? +test -w "${1}/.git/HEAD" + +# pull this repo +git --git-dir "${1}/.git" \ + --work-tree "${1}" \ + pull origin master + +exit $? diff --git a/git-hooks/generic b/git-hooks/generic new file mode 100755 index 0000000..bd127a6 --- /dev/null +++ b/git-hooks/generic @@ -0,0 +1,12 @@ +#!/bin/sh +# Generic hook, installs itself as a valid githook(5) and runs whatever it +# finds on hacking.hook.$self +# Format: +# hacking.hooks.post-receive.auto-deploy /srv/http/markpower.hackcoop.com.ar + +git config --local --get-regexp "hacking.hooks.${0}.*" | \ +while read hook repo; do + hook="`echo "${hook}" | cut -d'.' -f4`" + + ${HOME}/.ssh/git-hooks/${hook} ${repo} ${@} Date: Wed, 17 Apr 2013 17:14:47 -0300 Subject: It works\! --- git-hooks/generic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-hooks') diff --git a/git-hooks/generic b/git-hooks/generic index bd127a6..ebf56f4 100755 --- a/git-hooks/generic +++ b/git-hooks/generic @@ -4,7 +4,7 @@ # Format: # hacking.hooks.post-receive.auto-deploy /srv/http/markpower.hackcoop.com.ar -git config --local --get-regexp "hacking.hooks.${0}.*" | \ +git config -f config --get-regexp "hacking.hooks.$(basename ${0}).*" | \ while read hook repo; do hook="`echo "${hook}" | cut -d'.' -f4`" -- cgit v1.2.3-2-g168b From 8c0ba8357e629cc2eaef1d551618d14ac15b6493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Reynolds?= Date: Wed, 14 Aug 2013 12:19:36 -0300 Subject: Deploy current branch --- git-hooks/auto-deploy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git-hooks') diff --git a/git-hooks/auto-deploy b/git-hooks/auto-deploy index 0480756..02a22e7 100755 --- a/git-hooks/auto-deploy +++ b/git-hooks/auto-deploy @@ -8,9 +8,9 @@ set -e # Can we write on the clone? test -w "${1}/.git/HEAD" -# pull this repo -git --git-dir "${1}/.git" \ - --work-tree "${1}" \ - pull origin master +alias git="git --git-dir '${1}/.git' --work-tree '${1}'" + +# pull this repo on the current branch +git pull origin $(git rev-parse --abbrev-ref HEAD) exit $? -- cgit v1.2.3-2-g168b