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

Message ID 20230418140726.1472209-3-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series minor changes in script used for backports |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Thomas Monjalon April 18, 2023, 2:07 p.m. UTC
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@monjalon.net>
---
 devtools/git-log-fixes.sh | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
  

Comments

Luca Boccassi Nov. 28, 2023, 2:14 p.m. UTC | #1
On Tue, 18 Apr 2023 at 15:08, Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 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@monjalon.net>
> ---
>  devtools/git-log-fixes.sh | 22 ++++++----------------
>  1 file changed, 6 insertions(+), 16 deletions(-)

Acked-by: Luca Boccassi <bluca@debian.org>
  
Kevin Traynor Oct. 9, 2024, 9:17 a.m. UTC | #2
On 18/04/2023 15:07, Thomas Monjalon wrote:
> 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@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@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@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

Acked-by: Kevin Traynor <ktraynor@redhat.com>
  

Patch

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@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@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