Toyomasa Watarai
/
Mbed-example-WS-W27
Mbed Cloud example program for workshop in W27 2018.
easy-connect/.git/hooks/prepare-commit-msg.sample@0:119624335925, 2018-06-30 (annotated)
- Committer:
- MACRUM
- Date:
- Sat Jun 30 01:40:30 2018 +0000
- Revision:
- 0:119624335925
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:119624335925 | 1 | #!/bin/sh |
MACRUM | 0:119624335925 | 2 | # |
MACRUM | 0:119624335925 | 3 | # An example hook script to prepare the commit log message. |
MACRUM | 0:119624335925 | 4 | # Called by "git commit" with the name of the file that has the |
MACRUM | 0:119624335925 | 5 | # commit message, followed by the description of the commit |
MACRUM | 0:119624335925 | 6 | # message's source. The hook's purpose is to edit the commit |
MACRUM | 0:119624335925 | 7 | # message file. If the hook fails with a non-zero status, |
MACRUM | 0:119624335925 | 8 | # the commit is aborted. |
MACRUM | 0:119624335925 | 9 | # |
MACRUM | 0:119624335925 | 10 | # To enable this hook, rename this file to "prepare-commit-msg". |
MACRUM | 0:119624335925 | 11 | |
MACRUM | 0:119624335925 | 12 | # This hook includes three examples. The first comments out the |
MACRUM | 0:119624335925 | 13 | # "Conflicts:" part of a merge commit. |
MACRUM | 0:119624335925 | 14 | # |
MACRUM | 0:119624335925 | 15 | # The second includes the output of "git diff --name-status -r" |
MACRUM | 0:119624335925 | 16 | # into the message, just before the "git status" output. It is |
MACRUM | 0:119624335925 | 17 | # commented because it doesn't cope with --amend or with squashed |
MACRUM | 0:119624335925 | 18 | # commits. |
MACRUM | 0:119624335925 | 19 | # |
MACRUM | 0:119624335925 | 20 | # The third example adds a Signed-off-by line to the message, that can |
MACRUM | 0:119624335925 | 21 | # still be edited. This is rarely a good idea. |
MACRUM | 0:119624335925 | 22 | |
MACRUM | 0:119624335925 | 23 | case "$2,$3" in |
MACRUM | 0:119624335925 | 24 | merge,) |
MACRUM | 0:119624335925 | 25 | /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; |
MACRUM | 0:119624335925 | 26 | |
MACRUM | 0:119624335925 | 27 | # ,|template,) |
MACRUM | 0:119624335925 | 28 | # /usr/bin/perl -i.bak -pe ' |
MACRUM | 0:119624335925 | 29 | # print "\n" . `git diff --cached --name-status -r` |
MACRUM | 0:119624335925 | 30 | # if /^#/ && $first++ == 0' "$1" ;; |
MACRUM | 0:119624335925 | 31 | |
MACRUM | 0:119624335925 | 32 | *) ;; |
MACRUM | 0:119624335925 | 33 | esac |
MACRUM | 0:119624335925 | 34 | |
MACRUM | 0:119624335925 | 35 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
MACRUM | 0:119624335925 | 36 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" |