...

Text file src/github.com/datawire/ambassador/v2/tools/hooks/prepare-commit-msg

Documentation: github.com/datawire/ambassador/v2/tools/hooks

     1#!/usr/bin/env bash
     2#
     3# A git commit hook that will automatically append a DCO signoff to the bottom
     4# of any commit message that doesn't have one. This append happens after the git
     5# default message is generated, but before the user is dropped into the commit
     6# message editor.
     7#
     8# To enable this hook, run `make githooks`, or run the following from the root of
     9# the repo.
    10#
    11#
    12# $ ln -s tools/hooks/prepare-commit-msg .git/hooks/prepare-commit-msg
    13COMMIT_MESSAGE_FILE="$1"
    14AUTHOR=$(git var GIT_AUTHOR_IDENT)
    15SIGNOFF=$(echo $AUTHOR | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
    16# Check for DCO signoff message. If one doesn't exist, append one and then warn
    17# the user that you did so.
    18if ! $(grep -qs "^$SIGNOFF" "$COMMIT_MESSAGE_FILE") ; then
    19  echo -e "\n$SIGNOFF" >> "$COMMIT_MESSAGE_FILE"
    20  echo -e "Appended the following signoff to the end of the commit message:\n  $SIGNOFF\n"
    21fi

View as plain text