[PATCH 2/2] devtools: deduplicate function to mark fixes

Thomas Monjalon thomas at monjalon.net
Tue Apr 18 16:07:26 CEST 2023


In the commit 8070d8fecb4e ("devtools: add fixes flag to commit listing")
the function to mark a commit for "stable" was duplicated for "Fixes:" mark.

The code is a bit smaller by using a single function for both marks.

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 devtools/git-log-fixes.sh | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
index 4690dd4545..005e46f715 100755
--- a/devtools/git-log-fixes.sh
+++ b/devtools/git-log-fixes.sh
@@ -84,31 +84,21 @@ origin_version () # <origin_hash> ...
 	done | sort -uV | head -n1
 }
 
-# print a marker for stable tag presence
-stable_tag () # <hash>
+# print a marker for pattern presence in the commit message
+git_log_mark () # <hash> <pattern> <marker>
 {
-	if git log --format='%b' -1 $1 | grep -qi '^Cc: *stable at dpdk.org' ; then
-		echo 'S'
+	if git log --format='%b' -1 $1 | grep -qi "$2" ; then
+		echo "$3"
 	else
 		echo '-'
 	fi
 }
 
-# print a marker for fixes tag presence
-fixes_tag () # <hash>
-{
-        if git log --format='%b' -1 $1 | grep -qi '^Fixes: *' ; then
-                echo 'F'
-        else
-                echo '-'
-        fi
-}
-
 git log --oneline --reverse $range |
 while read id headline ; do
 	origins=$(origin_filter $id)
-	stable=$(stable_tag $id)
-	fixes=$(fixes_tag $id)
+	stable=$(git_log_mark $id '^Cc: *stable at dpdk.org' 'S')
+	fixes=$(git_log_mark $id '^Fixes:' 'F')
 	[ "$stable" = "S" ] || [ "$fixes" = "F" ] || [ -n "$origins" ] || continue
 	version=$(commit_version $id)
 	if [ -n "$origins" ] ; then
-- 
2.40.0



More information about the dev mailing list