From c34e0ed181243560844d6dd7363bec1f7fa72f2c Mon Sep 17 00:00:00 2001 From: Michal Koutný Date: Sep 21 2022 15:48:04 +0000 Subject: scripts/CKC: Search also CVE and generic references Sometimes it's useful to check that references exits, not the commit itself. --- diff --git a/scripts/check-kernel-commit b/scripts/check-kernel-commit index 47ec7e7..e9c87b4 100755 --- a/scripts/check-kernel-commit +++ b/scripts/check-kernel-commit @@ -5,11 +5,11 @@ usage() echo "Check whether a given list of commit is available in" echo "a given list of branches." echo - echo "Usage: ${0##*/} [branches.conf] commit_hash..." + echo "Usage: ${0##*/} [branches.conf] term..." echo echo "Parametes:" echo " branches.conf: file with the list of branches to be checked" - echo " commit_hash: hash of the commint to be found" + echo " term: hash of the commit|CVE|bsc to be found" } fetch_branches() @@ -41,7 +41,30 @@ else shift; fi -KBC_CHECK_HASHES="$*" +KBC_CHECK_TERMS="$*" + +term2regex() +{ + shopt nocasematch + local t=$1 + case $t in + # CVEs first + 2[0-9][0-9][0-9]-*) + t=cve-$t + ;& + cve-*) + echo "^References:.*$t" + ;; + # looks like a hash, look for commits + [a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*) + echo "^Git-commit:.*$t" + ;; + # treat rest as a generic reference + *) + echo "^References:.*$t" + ;; + esac +} check_branch() { @@ -55,12 +78,12 @@ check_branch() found="" missing="" - for hash in $KBC_CHECK_HASHES ; do - git grep "^Git-commit: *$hash" "remotes/origin/$branch" >/dev/null 2>&1 + for term in $KBC_CHECK_TERMS ; do + git grep -i "$(term2regex $term)" "remotes/origin/$branch" >/dev/null 2>&1 if [ $? -eq 0 ] ; then - found="$found $hash" + found="$found $term" else - missing="$missing $hash" + missing="$missing $term" fi done @@ -78,7 +101,7 @@ check_branch() if [ $verbose -ne 0 ] ; then echo " missing hash:" for hash in $missing ; do - echo " $hash" + echo " $term" done echo fi