rice

personal dot files and scripts for linux and macOS
Log | Files | Refs | README | LICENSE

prepare-commit-msg (431B)


      1 #!/bin/sh
      2 
      3 COMMIT_MSG_FILE=$1  # The git commit file.
      4 COMMIT_SOURCE=$2    # The current commit message.
      5 
      6 # Add "Signed-off-by: <user> <email>" to every commit message.
      7 SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
      8 git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
      9 if test -z "$COMMIT_SOURCE"; then
     10   /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
     11 fi