]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
github-ci: add cherry-pick line check
authorVictor Julien <vjulien@oisf.net>
Mon, 5 Sep 2022 07:08:39 +0000 (09:08 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 8 Dec 2023 20:15:40 +0000 (21:15 +0100)
.github/workflows/commits.yml
qa/validate-cp.sh [new file with mode: 0755]

index 04bbb3fdf96b86e22ebd21a9cab7fb45ad1d0078..12368cb54cfb835479e3572cf71a92cc20629f25 100644 (file)
@@ -78,6 +78,9 @@ jobs:
       - run: /usr/bin/git config --global --add safe.directory /__w/suricata/suricata
       - run: git fetch
       - run: git clone https://github.com/OISF/libhtp -b 0.5.x
+      - name: Checking Cherry-pick lines
+        run: |
+          ./qa/validate-cp.sh "${GITHUB_BASE_REF}"
       - name: Building all commits
         run: |
           echo "Building commits from ${GITHUB_BASE_REF}."
diff --git a/qa/validate-cp.sh b/qa/validate-cp.sh
new file mode 100755 (executable)
index 0000000..a3c6b1c
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+#set -x
+#set -e
+
+if [ $# -ne 1 ]; then
+    echo "call with base branch (e.g. master-5.0.x)"
+    exit 1;
+fi
+
+BASE=$1
+CHECK_BRANCH="${VALIDATE_CHECK_BRANCH:-remotes/origin/master}"
+
+test_cherrypicked_line() {
+    REV=$1
+    #echo "\"REV $REV\""
+
+    CHERRY=$(echo $REV | grep '(cherry picked from commit' | awk '{print $5}'|awk -F')' '{print $1}' || return 1)
+    git branch -a --contains $CHERRY | grep " $CHECK_BRANCH$" &> /dev/null
+    if [ "$?" -ne 0 ]; then
+        echo -n "ERROR $CHERRY not found in $CHECK_BRANCH"
+        return 1
+    else
+        echo -n "OK "
+    fi
+}
+
+for rev in $(git rev-list --reverse origin/${BASE}..HEAD); do
+    echo -n "COMMIT $rev: "
+
+    GREPOP=$(git log --format=%B -n 1 $rev | grep 'cherry picked from commit')
+    if [ ! -z "$GREPOP" ]; then
+        while IFS= read -r line; do
+            test_cherrypicked_line "$line" || exit 1
+        done <<< "$GREPOP"
+        echo
+    else
+        echo "not a cherry-pick"
+    fi
+done