From dfaefc053531399e9359f4d41054be4f7b597e45 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 28 May 2025 13:05:17 +0200 Subject: [PATCH] ci/check-cherry-picks: fail without proper cherry-pick When cherry-picking without -x or not cherry-picking at all, the check-cherry-picks job would usually remain green. This is annoying to deal with for reviewers, because "all green" still needs attention - have all commits been cherry-picked properly? If a commit was not cherry-picked correctly, either without -x or not at all, because it's a genuine commit to begin with, the reviewers attention is required anyway. Thus we can also let the job fail in this case. --- ci/check-cherry-picks.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/check-cherry-picks.sh b/ci/check-cherry-picks.sh index 0ef8ff904f4a..612174925f57 100755 --- a/ci/check-cherry-picks.sh +++ b/ci/check-cherry-picks.sh @@ -17,7 +17,7 @@ problem=0 # Not everyone calls their remote "origin" remote="$(git remote -v | grep -i 'NixOS/nixpkgs' | head -n1 | cut -f1 || true)" -commits="$(git rev-list -E -i --grep="cherry.*[0-9a-f]{40}" --reverse "$1..$2")" +commits="$(git rev-list --reverse "$1..$2")" while read -r new_commit_sha ; do if [ -z "$new_commit_sha" ] ; then @@ -34,11 +34,19 @@ while read -r new_commit_sha ; do original_commit_sha=$( git rev-list --max-count=1 --format=format:%B "$new_commit_sha" \ | grep -Ei -m1 "cherry.*[0-9a-f]{40}" \ - | grep -Eoi -m1 '[0-9a-f]{40}' + | grep -Eoi -m1 '[0-9a-f]{40}' || true ) if [ -z "$original_commit_sha" ] ; then - echo " ? Couldn't locate original commit hash in message" - [ "$GITHUB_ACTIONS" = 'true' ] && echo ::endgroup:: + if [ "$GITHUB_ACTIONS" = 'true' ] ; then + echo ::endgroup:: + echo -n "::error ::" + else + echo -n " ✘ " + fi + echo "Couldn't locate original commit hash in message" + echo "Note this should not necessarily be treated as a hard fail, but a reviewer's attention should" \ + "be drawn to it and github actions have no way of doing that but to raise a 'failure'" + problem=1 continue fi