Mercurial > hg > isophonics-drupal-site
annotate vendor/drupal/coder/.git/hooks/prepare-commit-msg.sample @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 1fec387a4317 |
children |
rev | line source |
---|---|
Chris@14 | 1 #!/bin/sh |
Chris@14 | 2 # |
Chris@14 | 3 # An example hook script to prepare the commit log message. |
Chris@14 | 4 # Called by "git commit" with the name of the file that has the |
Chris@14 | 5 # commit message, followed by the description of the commit |
Chris@14 | 6 # message's source. The hook's purpose is to edit the commit |
Chris@14 | 7 # message file. If the hook fails with a non-zero status, |
Chris@14 | 8 # the commit is aborted. |
Chris@14 | 9 # |
Chris@14 | 10 # To enable this hook, rename this file to "prepare-commit-msg". |
Chris@14 | 11 |
Chris@14 | 12 # This hook includes three examples. The first comments out the |
Chris@14 | 13 # "Conflicts:" part of a merge commit. |
Chris@14 | 14 # |
Chris@14 | 15 # The second includes the output of "git diff --name-status -r" |
Chris@14 | 16 # into the message, just before the "git status" output. It is |
Chris@14 | 17 # commented because it doesn't cope with --amend or with squashed |
Chris@14 | 18 # commits. |
Chris@14 | 19 # |
Chris@14 | 20 # The third example adds a Signed-off-by line to the message, that can |
Chris@14 | 21 # still be edited. This is rarely a good idea. |
Chris@14 | 22 |
Chris@14 | 23 case "$2,$3" in |
Chris@14 | 24 merge,) |
Chris@14 | 25 /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; |
Chris@14 | 26 |
Chris@14 | 27 # ,|template,) |
Chris@14 | 28 # /usr/bin/perl -i.bak -pe ' |
Chris@14 | 29 # print "\n" . `git diff --cached --name-status -r` |
Chris@14 | 30 # if /^#/ && $first++ == 0' "$1" ;; |
Chris@14 | 31 |
Chris@14 | 32 *) ;; |
Chris@14 | 33 esac |
Chris@14 | 34 |
Chris@14 | 35 # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
Chris@14 | 36 # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" |