Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions dco_verify_white_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
58da8ae48f274c3c602fe03eb7675b09d23340af
5 changes: 5 additions & 0 deletions support/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ if [ ! -e "${HOOKS_DIR}/prepare-commit-msg" ]; then
ln -sf "${HOOKS_DIR_RELPATH}/hooks/prepare-commit-msg" "${HOOKS_DIR}/prepare-commit-msg"
fi

if [ ! -e "${HOOKS_DIR}/commit-msg" ]; then
echo "Installing hook 'commit-msg'"
ln -sf "${HOOKS_DIR_RELPATH}/hooks/commit-msg" "${HOOKS_DIR}/commit-msg"
fi

if [ ! -e "${HOOKS_DIR}/pre-push" ]; then
echo "Installing hook 'pre-push'"
ln -sf "${HOOKS_DIR_RELPATH}/hooks/pre-push" "${HOOKS_DIR}/pre-push"
Expand Down
18 changes: 18 additions & 0 deletions support/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# A git commit hook that check the DCO signoff.
#
# To enable this hook, run `bootstrap`, or run the following from the root of
# the repo. (Note that `bootstrap` will correctly install this even if this code
# is located in a submodule, while the following won't.)
#
# $ ln -s ../../support/hooks/commit-msg .git/hooks/commit-msg

COMMIT_MESSAGE_FILE="$1"
SIGNOFF="Signed-off-by:"

# Check for DCO signoff message. If one doesn't exist, warn the user.
if ! grep -qs "^$SIGNOFF" "$COMMIT_MESSAGE_FILE"; then
echo -e "The commit doesn't have DCO signoff. Please ensure install the git hooks by './support/bootstrap'"
exit 1
fi
16 changes: 0 additions & 16 deletions support/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,6 @@ do
RANGE="$REMOTE_SHA..$LOCAL_SHA"
fi

# Verify DCO signoff. We do this before the format checker, since it has
# some probability of failing spuriously, while this check never should.
#
# In general, we can't assume that the commits are signed off by author
# pushing, so we settle for just checking that there is a signoff at all.
SIGNED_OFF=$(git rev-list --no-merges --grep "^Signed-off-by: " "$RANGE")
NOT_SIGNED_OFF=$(git rev-list --no-merges "$RANGE" | grep -Fxv "$SIGNED_OFF")
if [ -n "$NOT_SIGNED_OFF" ]
then
echo >&2 "ERROR: The following commits do not have DCO signoff:"
while read -r commit; do
echo " $(git log --pretty=oneline --abbrev-commit -n 1 "$commit")"
done <<< "$NOT_SIGNED_OFF"
exit 1
fi

# NOTE: The `tools` directory will be the same relative to the support
# directory, independent of whether we're in a submodule, so no need to use
# our `relpath` helper.
Expand Down