]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-pr-submodules: check for commit message noting submodule change 1943/head
authorKefu Chai <tchaikov@gmail.com>
Mon, 20 Dec 2021 13:40:02 +0000 (21:40 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 22 Dec 2021 14:15:56 +0000 (22:15 +0800)
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
ceph-pr-submodules/build/build

index ea0edff3c188b5232e54739f7378279277c986cc..2095ac6062aefd958303c0d139fb73519549546c 100644 (file)
@@ -30,9 +30,30 @@ function has_modified_submodules() {
     fi
 }
 
+function is_planned() {
+    local target_branch=$1
+    shift
+    local magic_word=$1
+    shift
+
+    IFS=$'\n'
+    for line in $(git log -z --no-merges origin/${target_branch}..HEAD); do
+        echo "${line}" | grep -q "${magic_word}" && return 0
+    done
+    # no lines match the magic word
+    return 1
+}
+
 if has_modified_submodules "${ghprbTargetBranch}" "${ghprbActualCommit}"; then
     echo "Project has modified submodules: $modified_submodules !"
-    exit 1
+    magic_word="$(basename $modified_submodules) submodule"
+    if is_planned "${ghprbTargetBranch}" "${magic_word}"; then
+        # ahh, it's planned
+        exit 0
+    else
+        echo "please include '${magic_word}' in your commit message, if this change is intentional."
+        exit 1
+    fi
 fi
 
 exit 0