From 0506efebfd091c8f8e30be323d75f456c03e005f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 2 Feb 2020 12:16:53 -0700 Subject: all git hooks use chained_hook script --- hooks/git/dgit/pre-push | 1 - hooks/git/dgit/pre-push_01signed-off-by | 1 + hooks/git/dotfiles/post-checkout | 23 ----------------- hooks/git/dotfiles/post-checkout_01gpgsign | 23 +++++++++++++++++ hooks/git/dotfiles/pre-push | 26 ------------------- hooks/git/dotfiles/pre-push_01gpgsign | 28 +++++++++++++++++++++ hooks/git/git-remote-gcrypt/pre-push | 1 - .../git/git-remote-gcrypt/pre-push_01signed-off-by | 1 + hooks/git/mailscripts/pre-push | 1 - hooks/git/mailscripts/pre-push_01signed-off-by | 1 + hooks/git/org-d20/pre-push | 1 - hooks/git/org-d20/pre-push_01signed-off-by | 1 + hooks/git/p5-Git-Annex/pre-push | 1 - hooks/git/p5-Git-Annex/pre-push_01signed-off-by | 1 + hooks/git/pandoc-citeproc-preamble/pre-push | 1 - .../pre-push_01signed-off-by | 1 + hooks/git/propellor/post-checkout | 29 ---------------------- hooks/git/propellor/post-checkout_01dirlocals | 29 ++++++++++++++++++++++ 18 files changed, 86 insertions(+), 84 deletions(-) delete mode 120000 hooks/git/dgit/pre-push create mode 120000 hooks/git/dgit/pre-push_01signed-off-by delete mode 100755 hooks/git/dotfiles/post-checkout create mode 100755 hooks/git/dotfiles/post-checkout_01gpgsign delete mode 100755 hooks/git/dotfiles/pre-push create mode 100755 hooks/git/dotfiles/pre-push_01gpgsign delete mode 120000 hooks/git/git-remote-gcrypt/pre-push create mode 120000 hooks/git/git-remote-gcrypt/pre-push_01signed-off-by delete mode 120000 hooks/git/mailscripts/pre-push create mode 120000 hooks/git/mailscripts/pre-push_01signed-off-by delete mode 120000 hooks/git/org-d20/pre-push create mode 120000 hooks/git/org-d20/pre-push_01signed-off-by delete mode 120000 hooks/git/p5-Git-Annex/pre-push create mode 120000 hooks/git/p5-Git-Annex/pre-push_01signed-off-by delete mode 120000 hooks/git/pandoc-citeproc-preamble/pre-push create mode 120000 hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by delete mode 100755 hooks/git/propellor/post-checkout create mode 100755 hooks/git/propellor/post-checkout_01dirlocals (limited to 'hooks') diff --git a/hooks/git/dgit/pre-push b/hooks/git/dgit/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/dgit/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/dgit/pre-push_01signed-off-by b/hooks/git/dgit/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/dgit/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/dotfiles/post-checkout b/hooks/git/dotfiles/post-checkout deleted file mode 100755 index 21b007cc..00000000 --- a/hooks/git/dotfiles/post-checkout +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -branch="$(git symbolic-ref --quiet --short HEAD)" -if ! [ $? = 0 ]; then # detached HEAD - git config commit.gpgsign false - exit 0 -fi - -# Check that signing is likely to succeed before setting -# commit.gpgsign, by looking for presence of a secret key with the -# signing capability. -# -# The reason this is needed is that this post-checkout hook will get -# called during a rebase onto master, and I want to do that on hosts -# which don't have access to my secret key. If commit.gpgsign gets -# set to true on those hosts, the rebase will be interrupted -if [ "$branch" = "master" ] \ - && gpg --list-secret-keys $(git config user.signingKey) 2>/dev/null \ - | grep -Eq '^(ssb|sec)[^#].*\[[A-Z]*S[A-Z]*\]$'; then - git config commit.gpgsign true -else - git config commit.gpgsign false -fi diff --git a/hooks/git/dotfiles/post-checkout_01gpgsign b/hooks/git/dotfiles/post-checkout_01gpgsign new file mode 100755 index 00000000..21b007cc --- /dev/null +++ b/hooks/git/dotfiles/post-checkout_01gpgsign @@ -0,0 +1,23 @@ +#!/bin/sh + +branch="$(git symbolic-ref --quiet --short HEAD)" +if ! [ $? = 0 ]; then # detached HEAD + git config commit.gpgsign false + exit 0 +fi + +# Check that signing is likely to succeed before setting +# commit.gpgsign, by looking for presence of a secret key with the +# signing capability. +# +# The reason this is needed is that this post-checkout hook will get +# called during a rebase onto master, and I want to do that on hosts +# which don't have access to my secret key. If commit.gpgsign gets +# set to true on those hosts, the rebase will be interrupted +if [ "$branch" = "master" ] \ + && gpg --list-secret-keys $(git config user.signingKey) 2>/dev/null \ + | grep -Eq '^(ssb|sec)[^#].*\[[A-Z]*S[A-Z]*\]$'; then + git config commit.gpgsign true +else + git config commit.gpgsign false +fi diff --git a/hooks/git/dotfiles/pre-push b/hooks/git/dotfiles/pre-push deleted file mode 100755 index a3f048dc..00000000 --- a/hooks/git/dotfiles/pre-push +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha; do - if [ "$local_sha" = $z40 ]; then - # Permit deletion of branches - : - else - if [ "$remote_ref" = "refs/heads/master" ]; then - if git verify-commit-by-fp \ - 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B "$local_sha" - then - echo "Proposed new master has been signed by Sean" - else - echo >&2 "Proposed new master has not been PGP-signed by Sean" - exit 1 - fi - fi - fi -done - -exit 0 diff --git a/hooks/git/dotfiles/pre-push_01gpgsign b/hooks/git/dotfiles/pre-push_01gpgsign new file mode 100755 index 00000000..1abc330b --- /dev/null +++ b/hooks/git/dotfiles/pre-push_01gpgsign @@ -0,0 +1,28 @@ +#!/bin/sh + +remote="$1" +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 + : + else + if [ "$remote_ref" = "refs/heads/master" ]; then + if git verify-commit-by-fp \ + 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B "$local_sha" + then + echo "Proposed new master has been signed by Sean" + else + echo >&2 "Proposed new master has not been PGP-signed by Sean" + exit 1 + fi + fi + fi +done + +exit 0 diff --git a/hooks/git/git-remote-gcrypt/pre-push b/hooks/git/git-remote-gcrypt/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/git-remote-gcrypt/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/git-remote-gcrypt/pre-push_01signed-off-by b/hooks/git/git-remote-gcrypt/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/git-remote-gcrypt/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/mailscripts/pre-push b/hooks/git/mailscripts/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/mailscripts/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/mailscripts/pre-push_01signed-off-by b/hooks/git/mailscripts/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/mailscripts/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/org-d20/pre-push b/hooks/git/org-d20/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/org-d20/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/org-d20/pre-push_01signed-off-by b/hooks/git/org-d20/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/org-d20/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/p5-Git-Annex/pre-push b/hooks/git/p5-Git-Annex/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/p5-Git-Annex/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/p5-Git-Annex/pre-push_01signed-off-by b/hooks/git/p5-Git-Annex/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/p5-Git-Annex/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/pandoc-citeproc-preamble/pre-push b/hooks/git/pandoc-citeproc-preamble/pre-push deleted file mode 120000 index 9ba9f82a..00000000 --- a/hooks/git/pandoc-citeproc-preamble/pre-push +++ /dev/null @@ -1 +0,0 @@ -../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by b/hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by new file mode 120000 index 00000000..9ba9f82a --- /dev/null +++ b/hooks/git/pandoc-citeproc-preamble/pre-push_01signed-off-by @@ -0,0 +1 @@ +../pre-push_signed-off-by \ No newline at end of file diff --git a/hooks/git/propellor/post-checkout b/hooks/git/propellor/post-checkout deleted file mode 100755 index 5118e81a..00000000 --- a/hooks/git/propellor/post-checkout +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Path::Class; -use autodie; - -(undef, my $head, my $flag) = @ARGV; -my $branch = `git name-rev --name-only $head`; -chomp $branch; - -if ( $flag && "$branch" ne "debian" ) { - # We create a cabal sandbox so that Emacs' haskell-mode ignores - # stack.yaml. We don't need to use stack because Propellor's deps - # are always installed as system packages - unless ( -d ".cabal-sandbox" ) { - system "cabal sandbox init"; - } - open my $fh, ">", ".dir-locals.el"; - print $fh <<'END'; -((nil . ((indent-tabs-mode . t) - (tab-width . 8) - (fill-column . 80))) - ;; Warn about spaces used for indentation: - (haskell-mode . ((eval . (highlight-regexp "^ +"))))) -END - close $fh; -} diff --git a/hooks/git/propellor/post-checkout_01dirlocals b/hooks/git/propellor/post-checkout_01dirlocals new file mode 100755 index 00000000..5118e81a --- /dev/null +++ b/hooks/git/propellor/post-checkout_01dirlocals @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Path::Class; +use autodie; + +(undef, my $head, my $flag) = @ARGV; +my $branch = `git name-rev --name-only $head`; +chomp $branch; + +if ( $flag && "$branch" ne "debian" ) { + # We create a cabal sandbox so that Emacs' haskell-mode ignores + # stack.yaml. We don't need to use stack because Propellor's deps + # are always installed as system packages + unless ( -d ".cabal-sandbox" ) { + system "cabal sandbox init"; + } + open my $fh, ">", ".dir-locals.el"; + print $fh <<'END'; +((nil . ((indent-tabs-mode . t) + (tab-width . 8) + (fill-column . 80))) + ;; Warn about spaces used for indentation: + (haskell-mode . ((eval . (highlight-regexp "^ +"))))) +END + close $fh; +} -- cgit v1.2.3