Skip to content

Commit

Permalink
Add git hook to check for DCO signoff.
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Yeh <[email protected]>
  • Loading branch information
enisoc committed Mar 1, 2018
1 parent c389235 commit d6d89fb
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 2 deletions.
37 changes: 37 additions & 0 deletions DCO
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ echo "creating git hooks"
mkdir -p $VTTOP/.git/hooks
ln -sf $VTTOP/misc/git/pre-commit $VTTOP/.git/hooks/pre-commit
ln -sf $VTTOP/misc/git/prepare-commit-msg.bugnumber $VTTOP/.git/hooks/prepare-commit-msg
ln -sf $VTTOP/misc/git/commit-msg.bugnumber $VTTOP/.git/hooks/commit-msg
ln -sf $VTTOP/misc/git/commit-msg $VTTOP/.git/hooks/commit-msg
(cd $VTTOP && git config core.hooksPath $VTTOP/.git/hooks)

# Download chromedriver
Expand Down
20 changes: 20 additions & 0 deletions misc/git/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Runs any hooks in misc/git/commit-msg.*, and exits if any of them fail.
set -e

# This is necessary because the Emacs extensions don't set GIT_DIR.
if [ -z "$GIT_DIR" ]; then
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
GIT_DIR="${DIR}/.."
fi

# This is necessary because the Atom packages don't set GOPATH
if [ -z "$GOPATH" ]; then
GOPATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../../../.." && pwd )
export GOPATH
fi

for hook in $GIT_DIR/../misc/git/commit-msg.*; do
$hook $@
done
35 changes: 35 additions & 0 deletions misc/git/commit-msg.signoff
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# This script is run during "git commit" after the commit message was entered.
#
# If it does not find a Signed-off-by: line in this commit,
# it prints a message about using the -s flag and a link
# to an explanation of the DCO.

msg_file="$1"

git_email="$(git config --get user.email)"
signoff="$(grep -E --max-count=1 "^Signed-off-by: " "$msg_file")"

if [[ "$signoff" =~ \<(.*)\> ]]; then
if [[ "${BASH_REMATCH[1]}" == "${git_email}" ]]; then
# Everything checks out!
exit 0
fi
fi

# No signoff found, or the email doesn't match. Print some instructions.
echo
echo "No 'Signed-off-by:' line was found, or the email didn't match"
echo "the commit author (${git_email})."
echo
echo "This project uses a Developer Certificate of Origin"
echo "instead of a Contributor License Agreement."
echo "For more information, see: https://wiki.linuxfoundation.org/dco"
echo
echo "Please certify this contribution meets the requirements in the"
echo "'DCO' file in the root of this repository by committing with"
echo "the --signoff flag:"
echo
echo " git commit --signoff"
exit 1
2 changes: 1 addition & 1 deletion misc/git/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Runs any hooks in mic/git/hooks, and exits if any of them fail.
# Runs any hooks in misc/git/hooks, and exits if any of them fail.
set -e

# This is necessary because the Emacs extensions don't set GIT_DIR.
Expand Down

0 comments on commit d6d89fb

Please sign in to comment.