diff options
author | Simo Sorce <simo@redhat.com> | 2019-03-29 14:01:14 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2019-04-01 14:39:49 -0400 |
commit | da1b11d158da5f1ec2a6ea7657923a7d1d5aaaca (patch) | |
tree | 736802532d0ec87f716547247d2a1f8796d530ed | |
parent | f2a6431b6e709f2287aca6075580313800828ad1 (diff) | |
download | gnutls-da1b11d158da5f1ec2a6ea7657923a7d1d5aaaca.tar.gz |
Fix check_if_signed
Fix the target branch we check against by adding upstream as remote.
Drop the use of set -e as this causes the shell to immediately exit on
errors instead of allowing the code to check the failure and report what
it faled about.
Also print which commits are being checked and what information was found
so that a CI failure can be better diagnosed.
Signed-off-by: Simo Sorce <simo@redhat.com>
-rwxr-xr-x | devel/check_if_signed | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/devel/check_if_signed b/devel/check_if_signed index 3d05d4fcbb..e7e5c504b2 100755 --- a/devel/check_if_signed +++ b/devel/check_if_signed @@ -1,27 +1,32 @@ #!/usr/bin/env bash -set -e +# MRs have the contributor git tree as the only remote +# Add GnuTLS Gitlab upstream tree as remote so we can compare against +# the right master tree -if test -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"; then - CI_MERGE_REQUEST_TARGET_BRANCH_NAME="origin/master" +git remote add gitlab-gnutls-upstream-git-tree https://gitlab.com/gnutls/gnutls.git +git fetch -q gitlab-gnutls-upstream-git-tree master + +if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]; then + CI_MERGE_REQUEST_TARGET_BRANCH_NAME="gitlab-gnutls-upstream-git-tree/master" fi echo "target=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" echo "source=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" -if test -z "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"; then - CI_MERGE_REQUEST_SOURCE_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) - echo "branch=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" -fi - # create list of commits of the current branch -commits=$(git rev-list --no-merges $CI_MERGE_REQUEST_TARGET_BRANCH_NAME..$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME) +commits=$(git rev-list --no-merges $CI_MERGE_REQUEST_TARGET_BRANCH_NAME..) +if [ -z "$commits" ]; then + echo "Couldn't find any commits to check" + exit 1 +fi # check if author's email matches email in 'Signed-off-by' for hash in $commits; do author=$(git log --format='%ae' ${hash}^\!) signed=$(git log --format='%b' ${hash}^\! | grep -i "Signed-off-by:") - if test $? -ne 0; then + echo "Checking commit $hash from Author $author and Signed-off-by: $signed" + if [ $? -ne 0 ]; then echo "Missing Signed-off-by" exit 1 fi |