Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions dco-signoff-hook/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@

#!/bin/sh
set -e

if [ -z "$1" ]; then
echo "Usage: $0 <file>"
exit 1
fi

NAME=$(git config user.name)
EMAIL=$(git config user.email)
if [ ! -f "$1" ]; then
echo "File not found: $1"
exit 2
fi

NAME=$(git config --get user.name)
EMAIL=$(git config --get user.email)

if [ -z "$NAME" ]; then
echo "empty git config user.name"
exit 1
exit 3
fi

if [ -z "$EMAIL" ]; then
echo "empty git config user.email"
exit 1
exit 4
fi

git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $NAME <$EMAIL>" \
--in-place "$1"
git interpret-trailers \
--if-exists addIfDifferent \
--trailer "Signed-off-by: $NAME <$EMAIL>" \
--in-place "$1"