[2/2] devtools: deduplicate function to mark fixes
Checks
Commit Message
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
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>
@@ -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