diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-02 12:16:53 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-02 12:16:53 -0700 |
commit | 0506efebfd091c8f8e30be323d75f456c03e005f (patch) | |
tree | 97345053c438053f65ba9dfba4b58a472a6d288e | |
parent | 3a7ad6cb7da8ef30bd12ce3ecdfd0c03a02cde44 (diff) | |
download | dotfiles-0506efebfd091c8f8e30be323d75f456c03e005f.tar.gz |
all git hooks use chained_hook script
-rw-r--r-- | .mrconfig.in | 19 | ||||
-rwxr-xr-x | bin/install-git-hooks | 47 | ||||
l--------- | hooks/git/dgit/pre-push_01signed-off-by (renamed from hooks/git/dgit/pre-push) | 0 | ||||
-rwxr-xr-x | hooks/git/dotfiles/post-checkout_01gpgsign (renamed from hooks/git/dotfiles/post-checkout) | 0 | ||||
-rwxr-xr-x | hooks/git/dotfiles/pre-push_01gpgsign (renamed from hooks/git/dotfiles/pre-push) | 2 | ||||
l--------- | hooks/git/git-remote-gcrypt/pre-push_01signed-off-by (renamed from hooks/git/git-remote-gcrypt/pre-push) | 0 | ||||
l--------- | hooks/git/mailscripts/pre-push_01signed-off-by (renamed from hooks/git/mailscripts/pre-push) | 0 | ||||
l--------- | hooks/git/org-d20/pre-push_01signed-off-by (renamed from hooks/git/org-d20/pre-push) | 0 | ||||
l--------- | hooks/git/p5-Git-Annex/pre-push_01signed-off-by (renamed from hooks/git/p5-Git-Annex/pre-push) | 0 | ||||
l--------- | hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by (renamed from hooks/git/pandoc-citeproc-preamble/pre-push) | 0 | ||||
-rwxr-xr-x | hooks/git/propellor/post-checkout_01dirlocals (renamed from hooks/git/propellor/post-checkout) | 0 |
11 files changed, 57 insertions, 11 deletions
diff --git a/.mrconfig.in b/.mrconfig.in index 1ca928ab..b69843d7 100644 --- a/.mrconfig.in +++ b/.mrconfig.in @@ -90,9 +90,6 @@ lib = # tucson() { # on artemis shortgeese athena hephaestus iris # } - install_git_hooks() { - cp -fs $HOME/src/dotfiles/hooks/git/$1/* "$MR_REPO/.git/hooks" - } # --- run a command on athena in a sane environment @@ -234,7 +231,7 @@ fixups = $HOME/src/dotfiles/bin/loadsshkeys || true fi # eventually move the following three lines from fixups to post_checkout - install_git_hooks dotfiles + install-git-hooks dotfiles git config commit.gpgsign true git config user.signingkey 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B @@ -328,7 +325,7 @@ post_checkout = # Propellor's coding style. We have to use a hook because # .dir-locals.el and the cabal sandbox must be nuked when working # with dgit on the 'debian' branch - install_git_hooks propellor + install-git-hooks propellor echo ".dir-locals.el" >>.git/info/exclude fixups = # check that the link isn't already in place before making the link @@ -356,7 +353,7 @@ post_checkout = cd dgit git remote add -f athena athena:dgit dgit setup-new-tree - install_git_hooks dgit + install-git-hooks dgit skip = lazy # [src/ublock-origin] @@ -377,28 +374,28 @@ skip = lazy [src/mailscripts] checkout = git clone 'athena:mailscripts' 'mailscripts' post_checkout = - install_git_hooks mailscripts + install-git-hooks mailscripts cd 'mailscripts'; dgit fetch buster-backports; dgit fetch sid skip = ! workstation [src/p5-Git-Annex] checkout = git clone 'athena:p5-Git-Annex' 'p5-Git-Annex' -post_checkout = install_git_hooks p5-Git-Annex +post_checkout = install-git-hooks p5-Git-Annex skip = lazy [src/org-d20] checkout = git clone 'athena:org-d20' 'org-d20' -post_checkout = install_git_hooks org-d20 +post_checkout = install-git-hooks org-d20 skip = lazy [src/git-remote-gcrypt] checkout = git clone 'athena:git-remote-gcrypt' 'git-remote-gcrypt' -post_checkout = install_git_hooks git-remote-gcrypt +post_checkout = install-git-hooks git-remote-gcrypt skip = ! workstation [src/pandoc-citeproc-preamble] checkout = git clone 'athena:pandoc-citeproc-preamble' 'pandoc-citeproc-preamble' -post_checkout = install_git_hooks pandoc-citeproc-preamble +post_checkout = install-git-hooks pandoc-citeproc-preamble skip = lazy # --- radicale collections diff --git a/bin/install-git-hooks b/bin/install-git-hooks new file mode 100755 index 00000000..1d461041 --- /dev/null +++ b/bin/install-git-hooks @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright (C) 2020 Sean Whitton +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use 5.028; +use strict; +use warnings; + +use File::Spec::Functions qw(catfile); +use List::Util qw(uniq); + +die "usage: install-git-hooks NAME\n" unless @ARGV == 1; +die "must be run by mr(1)\n" unless $ENV{MR_REPO}; + +my $source = catfile $ENV{HOME}, qw(src dotfiles hooks git), $ARGV[0]; +my $chained_hook = catfile $ENV{HOME}, qw(src dotfiles hooks git chained_hook); + +opendir(my $dirh, $source) or die "could not find $source dir\n"; +my @hooks = grep { $_ ne '.' and $_ ne '..' } readdir $dirh; +my @hook_types = uniq map { /^([^_]+)_/; $1 // () } @hooks; + +chdir $ENV{MR_REPO}; +my $config_hooks_path = `git config core.hooksPath`; +chomp(my $hook_dir = $config_hooks_path || `git rev-parse --git-path hooks`); + +foreach my $hook (@hooks) { + unlink catfile $hook_dir, $hook; + symlink catfile($source, $hook), catfile($hook_dir, $hook); +} + +foreach my $hook_type (@hook_types) { + unlink catfile $hook_dir, $hook_type; + symlink $chained_hook, catfile $hook_dir, $hook_type; +} diff --git a/hooks/git/dgit/pre-push b/hooks/git/dgit/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/dgit/pre-push +++ b/hooks/git/dgit/pre-push_01signed-off-by diff --git a/hooks/git/dotfiles/post-checkout b/hooks/git/dotfiles/post-checkout_01gpgsign index 21b007cc..21b007cc 100755 --- a/hooks/git/dotfiles/post-checkout +++ b/hooks/git/dotfiles/post-checkout_01gpgsign diff --git a/hooks/git/dotfiles/pre-push b/hooks/git/dotfiles/pre-push_01gpgsign index a3f048dc..1abc330b 100755 --- a/hooks/git/dotfiles/pre-push +++ b/hooks/git/dotfiles/pre-push_01gpgsign @@ -5,6 +5,8 @@ url="$2" z40=0000000000000000000000000000000000000000 +echo "me toooooo" + while read local_ref local_sha remote_ref remote_sha; do if [ "$local_sha" = $z40 ]; then # Permit deletion of branches diff --git a/hooks/git/git-remote-gcrypt/pre-push b/hooks/git/git-remote-gcrypt/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/git-remote-gcrypt/pre-push +++ b/hooks/git/git-remote-gcrypt/pre-push_01signed-off-by diff --git a/hooks/git/mailscripts/pre-push b/hooks/git/mailscripts/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/mailscripts/pre-push +++ b/hooks/git/mailscripts/pre-push_01signed-off-by diff --git a/hooks/git/org-d20/pre-push b/hooks/git/org-d20/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/org-d20/pre-push +++ b/hooks/git/org-d20/pre-push_01signed-off-by diff --git a/hooks/git/p5-Git-Annex/pre-push b/hooks/git/p5-Git-Annex/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/p5-Git-Annex/pre-push +++ b/hooks/git/p5-Git-Annex/pre-push_01signed-off-by diff --git a/hooks/git/pandoc-citeproc-preamble/pre-push b/hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by index 9ba9f82a..9ba9f82a 120000 --- a/hooks/git/pandoc-citeproc-preamble/pre-push +++ b/hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by diff --git a/hooks/git/propellor/post-checkout b/hooks/git/propellor/post-checkout_01dirlocals index 5118e81a..5118e81a 100755 --- a/hooks/git/propellor/post-checkout +++ b/hooks/git/propellor/post-checkout_01dirlocals |