SHARE
TWEET

Untitled

a guest Jun 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cat .git/hooks/prepare-commit-msg
  2. #!/bin/sh
  3. #
  4. # An example hook script to prepare the commit log message.
  5. # Called by "git commit" with the name of the file that has the
  6. # commit message, followed by the description of the commit
  7. # message's source.  The hook's purpose is to edit the commit
  8. # message file.  If the hook fails with a non-zero status,
  9. # the commit is aborted.
  10. #
  11. # To enable this hook, rename this file to "prepare-commit-msg".
  12.  
  13. # This hook includes three examples.  The first comments out the
  14. # "Conflicts:" part of a merge commit.
  15. #
  16. # The second includes the output of "git diff --name-status -r"
  17. # into the message, just before the "git status" output.  It is
  18. # commented because it doesn't cope with --amend or with squashed
  19. # commits.
  20. #
  21. # The third example adds a Signed-off-by line to the message, that can
  22. # still be edited.  This is rarely a good idea.
  23.  
  24. case "$2,$3" in
  25.   merge,)
  26.     /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
  27.  
  28. # ,|template,)
  29. #   /usr/bin/perl -i.bak -pe '
  30. #      print "\n" . `git diff --cached --name-status -r`
  31. #    if /^#/ && $first++ == 0' "$1" ;;
  32.  
  33.   *)
  34.      mv "$1" "$1".tmp
  35.      echo "["`git rev-parse --abbrev-ref HEAD`"] ">"$1" && tail -n +2 "$1".tmp>>"$1" && rm -f "$1".tmp;;
  36. esac
  37.  
  38. # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
  39. # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top