From 659469c1b8b08ac2a9a5893907a0ba8c2dcb2648 Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Sat, 10 Jul 2021 15:08:27 +0100 Subject: [PATCH] Update .drone.yml and sign-my-commit script ahead of pipeline updates. --- .drone.yml | 2 +- sign-my-commit | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index e5f993d5f..ec0fbd97f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ steps: SQUASHBOT_TOKEN: from_secret: SQUASHBOT_TOKEN commands: - - /scripts/squashbot + - /scripts/wrapper trigger: event: diff --git a/sign-my-commit b/sign-my-commit index ecca7647d..41ae8e4f3 100755 --- a/sign-my-commit +++ b/sign-my-commit @@ -20,6 +20,7 @@ usage() echo ' --ssh, sign using your ssh key' echo ' --push, force push result' echo ' --verify, check existing signature is correct' + echo ' --commit, verify this specific commit' echo ' --help, display this message' echo 'SSH specific options:' echo ' --key, (required for signing) specify SSH private key file to use' @@ -33,6 +34,7 @@ AUTH_METHOD='' MNTNER='' SSH_KEYFILE='' VERIFY_ONLY=0 +COMMIT_SHA='' ########################################################################## # parse arguments @@ -57,6 +59,10 @@ do --verify) VERIFY_ONLY=1 ;; + --commit) + shift + COMMIT_SHA="$1" + ;; --help) usage exit 0 @@ -85,7 +91,7 @@ if [ "$VERIFY_ONLY" -eq 1 ] then if [ -z "$MNTNER" ] then - MNTNER=$(git log -n 1 --format=format:%B | \ + MNTNER=$(git log ${COMMIT_SHA} -n 1 --format=format:%B | \ grep '^### mntner:' | \ cut -d':' -f2 | tr -d ' ') if [ -n "$MNTNER" ] @@ -96,7 +102,7 @@ then if [ -z "$AUTH_METHOD" ] then - AUTH_METHOD=$(git log -n 1 --format=format:%B | \ + AUTH_METHOD=$(git log ${COMMIT_SHA} -n 1 --format=format:%B | \ grep '^### method:' | \ cut -d':' -f2 | tr -d ' ') if [ -n "$AUTH_METHOD" ] @@ -234,7 +240,7 @@ verify_pgp() echo "Verifying PGP signature" # find the current commit hash - hash=$(git log -n 1 --format=format:%H) + hash=$(git log ${COMMIT_SHA} -n 1 --format=format:%H) # requires git 2.5 git verify-commit "$hash" @@ -321,13 +327,13 @@ verify_ssh() grep '^ssh-' | sed "s/^/${MNTNER} /" > "$afile" # extract the signed text from the git comment - text=$(git log -n 1 --format=format:%B | grep '^### text:' | + text=$(git log ${COMMIT_SHA} -n 1 --format=format:%B | grep '^### text:' | cut -d':' -f2 | tr -d ' ') # extract the SSH signature from the comment begin="-----BEGIN SSH SIGNATURE-----" end="-----END SSH SIGNATURE-----" - git log -n 1 --format=format:%B | \ + git log ${COMMIT_SHA} -n 1 --format=format:%B | \ sed "/^$begin\$/,/^$end\$/!d" > "$sfile" # and finally verify