diff options
| author | Leo Famulari <leo@famulari.name> | 2017-01-23 00:57:46 -0500 |
|---|---|---|
| committer | Leo Famulari <leo@famulari.name> | 2017-02-08 03:42:08 +0100 |
| commit | f0d0c5bb188455e0b82ee3089ba103ef71877c87 (patch) | |
| tree | f048dc0fa25b9932090041688996146fc4bc8cda /etc/git | |
| parent | 4621acfd8272fa93d0530faa5f015b26a194b587 (diff) | |
etc: The pre-push hook says which commits failed the signature check.
* etc/git/pre-push: Check each commit's signature individually so that
we can report which commits fail the check.
Diffstat (limited to 'etc/git')
| -rwxr-xr-x | etc/git/pre-push | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/etc/git/pre-push b/etc/git/pre-push index c894c5a9ecb..9206a2dfe53 100755 --- a/etc/git/pre-push +++ b/etc/git/pre-push | |||
| @@ -40,17 +40,29 @@ do | |||
| 40 | else | 40 | else |
| 41 | if [ "$remote_sha" = $z40 ] | 41 | if [ "$remote_sha" = $z40 ] |
| 42 | then | 42 | then |
| 43 | # New branch, examine all commits | 43 | # We are pushing a new branch. To prevent wasting too |
| 44 | range="$local_sha" | 44 | # much time for this relatively rare case, we examine |
| 45 | # all commits since the first signed commit, rather than | ||
| 46 | # the full history. This check *will* fail, and the user | ||
| 47 | # will need to temporarily disable the hook to push the | ||
| 48 | # new branch. | ||
| 49 | range="e3d0fcbf7e55e8cbe8d0a1c5a24d73f341d7243b..$local_sha" | ||
| 45 | else | 50 | else |
| 46 | # Update to existing branch, examine new commits | 51 | # Update to existing branch, examine new commits |
| 47 | range="$remote_sha..$local_sha" | 52 | range="$remote_sha..$local_sha" |
| 48 | fi | 53 | fi |
| 49 | 54 | ||
| 50 | # Verify the signatures of all commits being pushed. | 55 | # Verify the signatures of all commits being pushed. |
| 51 | git verify-commit $(git rev-list $range) >/dev/null 2>&1 | 56 | ret=0 |
| 52 | 57 | for commit in $(git rev-list $range) | |
| 53 | exit $? | 58 | do |
| 59 | if ! git verify-commit $commit >/dev/null 2>&1 | ||
| 60 | then | ||
| 61 | printf "%s failed signature check\n" $commit | ||
| 62 | ret=1 | ||
| 63 | fi | ||
| 64 | done | ||
| 65 | exit $ret | ||
| 54 | fi | 66 | fi |
| 55 | done | 67 | done |
| 56 | 68 | ||
