/ scripts / hooks / prepare-commit-message
prepare-commit-message
 1  #!/bin/sh
 2  # Automatically adds 'Signed-off-by:' to the commit message
 3  # based on git configuration
 4  
 5  NAME=$(git config user.name)
 6  EMAIL=$(git config user.email)
 7  
 8  if [ -z "$NAME" ]; then
 9      echo "empty git config user.name"
10      exit 1
11  fi
12  
13  if [ -z "$EMAIL" ]; then
14      echo "empty git config user.email"
15      exit 1
16  fi
17  
18  git interpret-trailers --if-exists doNothing --trailer \
19      "Signed-off-by: $NAME <$EMAIL>" \
20      --in-place "$1"