about summary refs log tree commit diff
path: root/src/ci/scripts
diff options
context:
space:
mode:
authorMukund Lakshman <yaymukund@gmail.com>2021-08-20 01:15:35 +0100
committerMukund Lakshman <yaymukund@gmail.com>2021-08-20 11:58:20 +0100
commitf19ba35bcedb7cf602f78d30ec126167bacb7c3f (patch)
treed06ae8b05248cbbc369fc429b778e338d69c3ed2 /src/ci/scripts
parentadc8cd3e62a2d23cdc20e2d3b282652a8c1900b3 (diff)
downloadrust-f19ba35bcedb7cf602f78d30ec126167bacb7c3f.tar.gz
rust-f19ba35bcedb7cf602f78d30ec126167bacb7c3f.zip
Add support for including non-backport commits.
Diffstat (limited to 'src/ci/scripts')
-rwxr-xr-xsrc/ci/scripts/verify-backported-commits.sh28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/ci/scripts/verify-backported-commits.sh b/src/ci/scripts/verify-backported-commits.sh
index 75efabe8bfc..1023e4b0e28 100755
--- a/src/ci/scripts/verify-backported-commits.sh
+++ b/src/ci/scripts/verify-backported-commits.sh
@@ -62,6 +62,11 @@ verify_cherries() {
     # Check each commit in <current>..<upstream>
     backport_sha=$(get_backport "$sha")
 
+    if [[ "$backport_sha" == "nothing" ]]; then
+      echo "✓ \`$sha\` backports nothing"
+      continue
+    fi
+
     if [[ -z "$backport_sha" ]]; then
       no_backports+=("$sha")
       continue
@@ -88,8 +93,8 @@ verify_cherries() {
         done
         echo
         echo "do not match any commits in \`$1\`. If this was intended, add the text"
-        echo '\`backport-of: <SHA of a commit already in master>\` somewhere in the'
-        echo 'message of each of these commits.'
+        echo '\`backport-of: <SHA of a commit already in master>\`'
+        echo 'somewhere in the message of each of these commits.'
         echo
         failure=1
   fi
@@ -112,12 +117,27 @@ verify_cherries() {
   return $failure
 }
 
-# Get the backport of a commit, or empty string if it does not exist.
+# Get the backport of a commit. It echoes one of:
+#
+# 1. A SHA of the backported commit
+# 2. The string "nothing"
+# 3. An empty string
 #
 # $1 = <sha>
 get_backport() {
+  # This regex is:
+  #
+  # ^.* - throw away any extra starting characters
+  # backport-of: - prefix
+  # \s\? - optional space
+  # \(\) - capture group
+  # [a-f0-9]\+\|nothing - a SHA or the text 'nothing'
+  # .* - throw away any extra ending characters
+  # \1 - replace it with the first match
+  # {s//\1/p;q} - print the first occurrence and quit
+  #
   git show -s --format=%B "$1" \
-    | sed -n 's/^.*backport-of:\s\?\([a-f0-9]\+\).*/\1/p'
+    | sed -n '/^.*backport-of:\s\?\([a-f0-9]\+\|nothing\).*/{s//\1/p;q}'
 }
 
 # Check if a commit is in master.