diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-03-20 12:04:23 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-03-20 12:05:05 +0100 |
commit | c7abfa595dda5b74b0386532dc6a685ab1c7f009 (patch) | |
tree | f5cc097784cc4b011a67844bfaf2817791a57006 /contrib/verify-commits/verify-commits.sh | |
parent | 29fef0b9039be4a9595d4ecc44bc77a06321fc10 (diff) | |
parent | adaa568722e59cde510c5fe1997c49cbb9d7db12 (diff) |
Merge pull request #5149
adaa568 Add script to verify all merge commits are signed (Matt Corallo)
Diffstat (limited to 'contrib/verify-commits/verify-commits.sh')
-rwxr-xr-x | contrib/verify-commits/verify-commits.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/contrib/verify-commits/verify-commits.sh b/contrib/verify-commits/verify-commits.sh new file mode 100755 index 0000000000..5841fa2077 --- /dev/null +++ b/contrib/verify-commits/verify-commits.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +DIR=$(dirname "$0") + +echo "Please verify all commits in the following list are not evil:" +git log "$DIR" + +VERIFIED_ROOT=$(cat "${DIR}/trusted-git-root") + +HAVE_FAILED=false +IS_SIGNED () { + if [ $1 = $VERIFIED_ROOT ]; then + return 0; + fi + if ! git -c "gpg.program=${DIR}/gpg.sh" verify-commit $1 > /dev/null 2>&1; then + return 1; + fi + local PARENTS=$(git show -s --format=format:%P $1) + for PARENT in $PARENTS; do + if IS_SIGNED $PARENT > /dev/null; then + return 0; + fi + done + if ! "$HAVE_FAILED"; then + echo "No parent of $1 was signed with a trusted key!" > /dev/stderr + echo "Parents are:" > /dev/stderr + for PARENT in $PARENTS; do + git show -s $PARENT > /dev/stderr + done + HAVE_FAILED=true + fi + return 1; +} + +if [ x"$1" = "x" ]; then + TEST_COMMIT="HEAD" +else + TEST_COMMIT="$1" +fi + +IS_SIGNED "$TEST_COMMIT" +RES=$? +if [ "$RES" = 1 ]; then + if ! "$HAVE_FAILED"; then + echo "$TEST_COMMIT was not signed with a trusted key!" + fi +else + echo "There is a valid path from $TEST_COMMIT to $VERIFIED_ROOT where all commits are signed!" +fi + +exit $RES |