Skip to contentSkip to conversation

devtools: fix version pattern for fix search

PATCH Superseded Xueming Li 4 participants 19 messages Jun 12, 2021 – Aug 21, 2024

lore
Share & tools
lore

Xueming Li

author
#0 lore raw

PATCH 1/2 devtools: fix version pattern for fix search

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +3 -2
index 210c8dcf25..5fc57da913 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+	local VER="v*.*"
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l $VER --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/2 devtools: fix version pattern for fix search

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +3 -2
index 210c8dcf25..5fc57da913 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+	local VER="v*.*"
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l $VER --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v2 1/2 devtools: fix version pattern for fix search

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +3 -2
index 210c8dcf25..153ba5b438 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+	local VER="v*.*"
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l "$VER" --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v2 2/2 devtools: fix patches missing if range newer than HEAD

Current fix scan scripts scanned specified range in HEAD branch. When users ran it in an earlier branch, few patches were scanned due to the fixes in the range are newer and not merged to HEAD branch.

This patch introduces optional <branch> argument, default to HEAD if not specified. Checks the <range> specified in parameter must being merged in <branch>.

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
Cc Christian Ehrhardt <[email protected]>
---
 devtools/git-log-fixes.sh | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
devtools/git-log-fixes.sh +17 -6
index 153ba5b438..51d8b19942 100755
@@ -4,7 +4,7 @@
 
 print_usage ()
 {
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"
 }
 
 print_help ()
@@ -15,6 +15,7 @@ print_help ()
 	Find fixes to backport on previous versions.
 	It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
 	The oldest bug origin is printed as well as partially fixed versions.
+	It looks into current branch or the branch specified.
 	END_OF_HELP
 }
 
@@ -33,14 +34,22 @@ while getopts h ARG ; do
 done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
-range="$*"
+range="$1"
+branch="$2"
+
+[ -n "$branch" ] || branch="HEAD"
+refbranch=$(git rev-parse --abbrev-ref $branch)
+range_last=$(git log --oneline $range |head -n1|cut -d' ' -f1)
+if ! git branch -a --contains $range_last |grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
@@ -49,9 +58,11 @@ commit_version () # <hash>
 			sed "s,.\+,$t,"
 		done) |
 		head -n1)
-	if [ -z "$tag" ] ; then
-		# before -rc1 tag of release in progress
-		cat VERSION | cut -d'.' -f-2
+	if [ -z "$tag" ]; then
+		if [ "$branch" = 'HEAD' ]; then
+			# before -rc1 tag of release in progress
+			cat VERSION | cut -d'.' -f-2
+		fi
 	else
 		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
 	fi
Signature · 1 line
2.25.1
#4 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] devtools: fix patches missing if range newer than HEAD

30/06/2021 08:34, Xueming Li:

Quoted 1 line

Current fix scan scripts scanned specified range in HEAD branch.

I cannot parse the above sentence.

Quoted 3 lines

When users ran it in an earlier branch, few patches were scanned due to the fixes in the range are newer and not merged to HEAD branch.

You mean some patches were not scanned?

Quoted 4 lines

This patch introduces optional <branch> argument, default to HEAD if not specified. Checks the <range> specified in parameter must being merged in <branch>.

Cannot parse either.

Quoted 6 lines
Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
Cc Christian Ehrhardt <[email protected]>

[...]

Quoted 2 lines
devtools/git-log-fixes.sh +1 -1
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"

[...]

devtools/git-log-fixes.sh while getopts h ARG ; do · line 37

Quoted 2 lines
devtools/git-log-fixes.sh +1 -1
-range="$*"
+range="$1"

I think it breaks passing range in multiple parameters without quotes. But it is not really a problem.

devtools/git-log-fixes.sh while getopts h ARG ; do · line 41

Quoted 4 lines
devtools/git-log-fixes.sh +4 -0
+branch="$2"
+
+[ -n "$branch" ] || branch="HEAD"
+refbranch=$(git rev-parse --abbrev-ref $branch)

Why this line is needed? A comment may help. If $branch is not used anymore, we can overwrite it instead of introducing one more variable $refbranch.

Quoted 1 line

+range_last=$(git log --oneline $range |head -n1|cut -d' ' -f1)

spaces missing around pipes.
You can avoid "head" and "cut" by providing the right options to git.

devtools/git-log-fixes.sh while getopts h ARG ; do · line 43

Quoted 11 lines
devtools/git-log-fixes.sh +4 -1
+if ! git branch -a --contains $range_last |grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)

You move a line but not its comment above.

#5 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 2/2] devtools: fix patches missing if range newer than HEAD

Quoted 10 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Sunday, August 8, 2021 7:25 PM
To: Xueming(Steven) Li <[email protected]>
Cc: [email protected]; [email protected]; Christian Ehrhardt <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-stable] [PATCH v2 2/2] devtools: fix patches missing if range newer than HEAD

Quoted 4 lines

30/06/2021 08:34, Xueming Li:

Quoted 1 line

Current fix scan scripts scanned specified range in HEAD branch.

I cannot parse the above sentence.

The scripts scans patches and try to get patch version info from current branch.

Quoted 5 lines
Quoted 3 lines

When users ran it in an earlier branch, few patches were scanned due to the fixes in the range are newer and not merged to HEAD branch.

You mean some patches were not scanned?

Scanned but failed to retrieve correct version info.

Quoted 25 lines
Quoted 5 lines

This patch introduces optional <branch> argument, default to HEAD if not specified. Checks the <range> specified in parameter must being merged in <branch>.

Cannot parse either.

Quoted 7 lines
Fixes 752d8e097ec1 ("scripts: show fixes with release version of

bug")
Cc: Thomas Monjalon <[email protected]>
Cc: [email protected]
Cc: Christian Ehrhardt <[email protected]>

[...]

Quoted 2 lines
devtools/git-log-fixes.sh +1 -1
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"

[...]

devtools/git-log-fixes.sh while getopts h ARG ; do · line 37

Quoted 2 lines
devtools/git-log-fixes.sh +1 -1
-range="$*"
+range="$1"

I think it breaks passing range in multiple parameters without quotes. But it is not really a problem.

Quoted 6 lines

devtools/git-log-fixes.sh while getopts h ARG ; do · line 41

Quoted 4 lines
devtools/git-log-fixes.sh +4 -0
+branch="$2"
+
+[ -n "$branch" ] || branch="HEAD"
+refbranch=$(git rev-parse --abbrev-ref $branch)

Why this line is needed? A comment may help.

OK

Quoted 1 line

If $branch is not used anymore, we can overwrite it instead of introducing one more variable $refbranch.

$branch will be used in function commit_version().

Quoted 5 lines
Quoted 2 lines

+range_last=$(git log --oneline $range |head -n1|cut -d' ' -f1)

spaces missing around pipes.
You can avoid "head" and "cut" by providing the right options to git.

Yes, rev-parse will do this efficiently.

Quoted 14 lines

devtools/git-log-fixes.sh while getopts h ARG ; do · line 43

Quoted 11 lines
devtools/git-log-fixes.sh +4 -0
+if ! git branch -a --contains $range_last |grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit  commit_version () # <hash>

{

devtools/git-log-fixes.sh +0 -1
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)

You move a line but not its comment above.

#6 lore raw
In reply to Xueming Li

30/06/2021 08:34, Xueming Li:

Quoted 25 lines

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +0 -0
index 210c8dcf25..153ba5b438 100755

devtools/git-log-fixes.sh range="$*" · line 41

Quoted 4 lines
devtools/git-log-fixes.sh +1 -0
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+	local VER="v*.*"

Which tag is it supposed to match? What would not be matched? What about something like v19.11.8 ?
What about the above example 20.11_backport_202010506?

devtools/git-log-fixes.sh range="$*" · line 44

Quoted 4 lines
devtools/git-log-fixes.sh +1 -1
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||

Why adding "--sort=creatordate" ?
It is not mentioned in the commit log.

Quoted 7 lines
devtools/git-log-fixes.sh +1 -1
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l "$VER" --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
#7 lore raw

Hi,

Quoted 30 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Sunday, August 8, 2021 7:15 PM
To: Xueming(Steven) Li <[email protected]>
Cc: [email protected]; [email protected]; Christian Ehrhardt <[email protected]>; [email protected]; Luca Boccassi <[email protected]>
Subject: Re: [dpdk-stable] [PATCH v2 1/2] devtools: fix version pattern for fix search

30/06/2021 08:34, Xueming Li:

Quoted 21 lines

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of

bug")
Cc: Thomas Monjalon <[email protected]>
Cc: [email protected]

---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 12 lines

devtools/git-log-fixes.sh range="$*" · line 40

Quoted 8 lines
devtools/git-log-fixes.sh +1 -0
index 210c8dcf25..153ba5b438 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit  commit_version () # <hash>
 {
+	local VER="v*.*"

Which tag is it supposed to match? What would not be matched? What about something like v19.11.8 ?
What about the above example 20.11_backport_202010506?

It matches any tag version like started with "v" and a "." in the middle. So v19.11.8 matches as at least one "." in the middle. 20.11_backport_202010506 can't match since it not started with "v"

Quoted 8 lines

devtools/git-log-fixes.sh range="$*" · line 44

Quoted 5 lines
devtools/git-log-fixes.sh +1 -1
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||

Why adding "--sort=creatordate" ?
It is not mentioned in the commit log.

Mentioned a little bit: "select the most early tag"
By default git output tag in alpha order, this makes v19.11 appears earlier than v2.x, that's wrong.

Quoted 13 lines
Quoted 8 lines
devtools/git-log-fixes.sh +1 -1
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l "$VER" --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
Reviewed-by on v1 1/2
#8 lore raw
In reply to Xueming Li
Quoted 31 lines · Xueming Li

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +1 -0
index 210c8dcf25..5fc57da913 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+       local VER="v*.*"
        # use current branch as history reference
        local refbranch=$(git rev-parse --abbrev-ref HEAD)

devtools/git-log-fixes.sh range="$*"

Quoted 10 lines
devtools/git-log-fixes.sh +2 -3
-       local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+       local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
                # tag --merged option has been introduced in git 2.7.0
                # below is a fallback in case of old git version
-               for t in $(git tag -l --contains $1) ; do
+               for t in $(git tag -l $VER --contains $1) ; do
                        git branch $refbranch --contains $t |
                        sed "s,.\+,$t,"
                done) |
--

LGTM - thanks for improving the scripts!

Quoted 2 lines

2.25.1

Signature · 3 lines
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd
author
#9 lore raw

PATCH 2/2 devtools: auto detect branch to search fix patches

In reply to Xueming Li

Current fix scan scripts scanned specified range in current(HEAD) branch. When users run it in a earlier branch, few patches were scanned.

This patch auto etects branch to scan from range.

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
devtools/git-log-fixes.sh +3 -1
index 5fc57da913..9a8a9d6739 100755
@@ -34,13 +34,15 @@ done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
 range="$*"
+range_last=$(git log --oneline v21.05-rc3..v21.05 |head -n1|cut -d' ' -f1)
+# use first branch
+refbranch=$(git branch --contains $range_last -r --sort=-authordate |head -n1)
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
Signature · 1 line
2.25.1
#10 lore raw

Re: [dpdk-dev] [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 3 lines · Xueming Li

Current fix scan scripts scanned specified range in current(HEAD) branch. When users run it in a earlier branch, few patches were

^^ typo missing "an" (if you care)

Quoted 3 lines

scanned.

This patch auto etects branch to scan from range.

^^ typo missing "d" (if you care)

Quoted 14 lines
Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
devtools/git-log-fixes.sh +0 -0
index 5fc57da913..9a8a9d6739 100755

devtools/git-log-fixes.sh done · line 37

Quoted 4 lines
devtools/git-log-fixes.sh +1 -0
@@ -34,13 +34,15 @@ done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
 range="$*"
+range_last=$(git log --oneline v21.05-rc3..v21.05 |head -n1|cut -d' ' -f1)

Instead of these values that would need to be dynamic to be generally reliable right?
Everyone might need something different.

I thought about the same and wondered if this script should get a new optional argument.
If passed it will use this new argument instead of $refbranch

That would allow any user today to be able to continue to use it as-is and anyone else can for reliable behavior define the branch to look in.

Quoted 15 lines
devtools/git-log-fixes.sh +2 -2
+# use first branch
+refbranch=$(git branch --contains $range_last -r --sort=-authordate |head -n1)
 
 # get major release version of a commit
 commit_version () # <hash>
 {
        local VER="v*.*"
        # use current branch as history reference
-       local refbranch=$(git rev-parse --abbrev-ref HEAD)
        local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
                # tag --merged option has been introduced in git 2.7.0
                # below is a fallback in case of old git version
--

2.25.1

Signature · 3 lines
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd
#11 lore raw

Re: [dpdk-dev] [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 15 lines

-----Original Message-----
From: Christian Ehrhardt <[email protected]>
Sent: Monday, June 14, 2021 10:16 PM
To: Xueming(Steven) Li <[email protected]>
Cc: dev <[email protected]>; Luca Boccassi <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; dpdk stable <[email protected]>; Yuanhan Liu <[email protected]>
Subject: Re: [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 3 lines · Xueming Li

Current fix scan scripts scanned specified range in current(HEAD) branch. When users run it in a earlier branch, few patches were

Quoted 7 lines

^^ typo missing "an" (if you care)

Quoted 3 lines

scanned.

This patch auto etects branch to scan from range.

^^ typo missing "d" (if you care)

Thanks :)

Quoted 25 lines
Quoted 16 lines
Fixes 752d8e097ec1 ("scripts: show fixes with release version of

bug")

---
 devtools/git-log-fixes.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
devtools/git-log-fixes.sh +0 -0
index 5fc57da913..9a8a9d6739 100755

devtools/git-log-fixes.sh done · line 38

Quoted 5 lines
devtools/git-log-fixes.sh +2 -0
@@ -34,13 +34,15 @@ done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
 range="$*"
+range_last=$(git log --oneline v21.05-rc3..v21.05 |head -n1|cut -d' '
+-f1)

Instead of these values that would need to be dynamic to be generally reliable right? Everyone might need something different.

Quoted 5 lines

I thought about the same and wondered if this script should get a new optional argument. If passed it will use this new argument instead of $refbranch

That would allow any user today to be able to continue to use it as-is and anyone else can for reliable behavior define the branch to look in.

Looks good. There are two scenarios for this script:
Called from check-git-log.sh: if version not found, default to VERSION file Standalone running with range: I don't think a default is required.
So the default version only valid when "branch" argument is "HEAD"

Quoted 22 lines
Quoted 14 lines
devtools/git-log-fixes.sh +3 -2
+# use first branch
+refbranch=$(git branch --contains $range_last -r --sort=-authordate
+|head -n1)
 
 # get major release version of a commit  commit_version () # <hash>
 {
        local VER="v*.*"
        # use current branch as history reference
-       local refbranch=$(git rev-parse --abbrev-ref HEAD)
        local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
                # tag --merged option has been introduced in git 2.7.0
                # below is a fallback in case of old git version
--
Quoted 2 lines

2.25.1

--
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

#12 lore raw

Re: [dpdk-dev] [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 65 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming(Steven) Li
Sent: Tuesday, June 15, 2021 6:56 PM
To: Christian Ehrhardt <[email protected]>
Cc: dev <[email protected]>; Luca Boccassi <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; dpdk stable <[email protected]>; Yuanhan Liu <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 15 lines

-----Original Message-----
From: Christian Ehrhardt <[email protected]>
Sent: Monday, June 14, 2021 10:16 PM
To: Xueming(Steven) Li <[email protected]>
Cc: dev <[email protected]>; Luca Boccassi <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; dpdk stable <[email protected]>; Yuanhan Liu <[email protected]>
Subject: Re: [PATCH 2/2] devtools: auto detect branch to search fix patches

Quoted 3 lines · Xueming Li

Current fix scan scripts scanned specified range in current(HEAD) branch. When users run it in a earlier branch, few patches were

Quoted 7 lines

^^ typo missing "an" (if you care)

Quoted 3 lines

scanned.

This patch auto etects branch to scan from range.

^^ typo missing "d" (if you care)

Thanks :)

Quoted 28 lines
Quoted 16 lines
Fixes 752d8e097ec1 ("scripts: show fixes with release version of

bug")

---
 devtools/git-log-fixes.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
devtools/git-log-fixes.sh +0 -0
index 5fc57da913..9a8a9d6739 100755

devtools/git-log-fixes.sh done · line 38

Quoted 5 lines
devtools/git-log-fixes.sh +2 -0
@@ -34,13 +34,15 @@ done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
 range="$*"
+range_last=$(git log --oneline v21.05-rc3..v21.05 |head -n1|cut -d' '
+-f1)

Instead of these values that would need to be dynamic to be generally reliable right? Everyone might need something different.

I thought about the same and wondered if this script should get a new optional argument. If passed it will use this new argument instead of $refbranch

Quoted 7 lines
Quoted 2 lines

That would allow any user today to be able to continue to use it as-is and anyone else can for reliable behavior define the branch to look in.

Looks good. There are two scenarios for this script:
Called from check-git-log.sh: if version not found, default to VERSION file Standalone running with range: I don't think a default is required.
So the default version only valid when "branch" argument is "HEAD"

It might not be a good idea to "guess" the branch from commit range.
V2 adds branch parameter, default to HEAD, then verifies branch contains the commit range.

Now in any branch, below command works correctly:

	devtools/git-log-fixes.sh v21.05-rc1..v21.05 origin/main
If current branch is older, like 20.11, below command will abort with error:
	devtools/git-log-fixes.sh v21.05-rc1..v21.05
Quoted 23 lines
Quoted 23 lines
Quoted 15 lines
devtools/git-log-fixes.sh +3 -2
+# use first branch
+refbranch=$(git branch --contains $range_last -r --sort=-authordate
+|head -n1)
 
 # get major release version of a commit  commit_version () # <hash>
 {
        local VER="v*.*"
        # use current branch as history reference
-       local refbranch=$(git rev-parse --abbrev-ref HEAD)
        local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
                # tag --merged option has been introduced in git 2.7.0
                # below is a fallback in case of old git version
--
Quoted 2 lines

2.25.1

--
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

author
#13 lore raw

PATCH 2/2 devtools: auto detect branch to search fix patches

In reply to Xueming Li

Current fix scan scripts scanned specified range in current(HEAD) branch. When users run it in an earlier branch, few patches were scanned.

This patch introduces optional <branch> argument, auto detects from range if not provided.

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/check-git-log.sh |  2 +-
 devtools/git-log-fixes.sh | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)
devtools/check-git-log.sh +1 -1
index 9988bf863d..b463110a90 100755
@@ -51,7 +51,7 @@ commits=$(git log --format='%h' --reverse $range)
 headlines=$(git log --format='%s' --reverse $range)
 bodylines=$(git log --format='%b' --reverse $range)
 fixes=$(git log --format='%h %s' --reverse $range | grep -i ': *fix' | cut -d' ' -f1)
-stablefixes=$($selfdir/git-log-fixes.sh $range | sed '/(N\/A)$/d'  | cut -d' ' -f2)
+stablefixes=$($selfdir/git-log-fixes.sh $range HEAD | sed '/(N\/A)$/d'  | cut -d' ' -f2)
 tags=$(git log --format='%b' --reverse $range | grep -i -e 'by *:' -e 'fix.*:')
 bytag='\(Reported\|Suggested\|Signed-off\|Acked\|Reviewed\|Tested\)-by:'
 
devtools/git-log-fixes.sh +18 -6
index 5fc57da913..9d2d0ef96c 100755
@@ -4,7 +4,7 @@
 
 print_usage ()
 {
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [branch]"
 }
 
 print_help ()
@@ -15,6 +15,7 @@ print_help ()
 	Find fixes to backport on previous versions.
 	It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
 	The oldest bug origin is printed as well as partially fixed versions.
+	It looks into the branch specified, otherwise any branch contains the range.
 	END_OF_HELP
 }
 
@@ -33,14 +34,23 @@ while getopts h ARG ; do
 done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
-range="$*"
+range="$1"
+branch="$2"
+
+if [ -z "$branch" ] ; then
+	# last commit in range
+	range_last=$(git log --oneline v21.05-rc3..v21.05 |head -n1|cut -d' ' -f1)
+	# use first branch contains the commit
+	refbranch=$(git branch --contains $range_last -r --sort=-authordate |head -n1)
+else
+	refbranch=$(git rev-parse --abbrev-ref $branch)
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l $VER --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
@@ -49,9 +59,11 @@ commit_version () # <hash>
 			sed "s,.\+,$t,"
 		done) |
 		head -n1)
-	if [ -z "$tag" ] ; then
-		# before -rc1 tag of release in progress
-		cat VERSION | cut -d'.' -f-2
+	if [ -z "$tag" ]; then
+		if [ "$branch" = 'HEAD' ]; then
+			# before -rc1 tag of release in progress
+			cat VERSION | cut -d'.' -f-2
+		fi
 	else
 		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
 	fi
Signature · 1 line
2.25.1
author
#14 lore raw

PATCH v3 1/2 devtools: fix version pattern for fix search

In reply to Xueming Li

When scanning fixes from current(HEAD) branch, local tags were included and reported as version. For example:

  $ git tag --contains <commit_id> --merged
  20.11_backport_202010506   // user tag
  v20.11
  v20.11.1

This patch matches DPDK officail version pattern in search, selects the most early tag. Official tag pattern: "v<major>.<minor>"

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
---
 devtools/git-log-fixes.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
devtools/git-log-fixes.sh +3 -2
index 210c8dcf25..153ba5b438 100755
@@ -38,12 +38,13 @@ range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
+	local VER="v*.*"
 	# use current branch as history reference
 	local refbranch=$(git rev-parse --abbrev-ref HEAD)
-	local tag=$( (git tag -l --contains $1 --merged $refbranch 2>&- ||
+	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
-		for t in $(git tag -l --contains $1) ; do
+		for t in $(git tag -l "$VER" --contains $1) ; do
 			git branch $refbranch --contains $t |
 			sed "s,.\+,$t,"
 		done) |
Signature · 1 line
2.25.1
author
#15 lore raw

PATCH v3 2/2 devtools: fix patches missing if range newer than HEAD

Current fix scan scripts used HEAD branch as history reference. When users ran it in an earlier branch, few patches were scanned due to the fixes in the range are newer and not merged to current branch.

This patch introduces optional <branch> argument, default to HEAD if not specified. Checks the <range> specified in parameter must being merged in <branch>.

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
Cc Christian Ehrhardt <[email protected]>
---
 devtools/git-log-fixes.sh | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
devtools/git-log-fixes.sh +19 -7
index 153ba5b438..dbed4b6419 100755
@@ -4,7 +4,7 @@
 
 print_usage ()
 {
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"
 }
 
 print_help ()
@@ -15,6 +15,7 @@ print_help ()
 	Find fixes to backport on previous versions.
 	It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
 	The oldest bug origin is printed as well as partially fixed versions.
+	It looks into current branch or the branch specified.
 	END_OF_HELP
 }
 
@@ -33,14 +34,23 @@ while getopts h ARG ; do
 done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
-range="$*"
+range="$1"
+branch="$2"
+
+# default to current branch as history reference
+[ -n "$branch" ] || branch="HEAD"
+# get real brnach name
+refbranch=$(git rev-parse --abbrev-ref $branch)
+range_last=$(git rev-parse $range | head -n1)
+if ! git branch -a --contains $range_last | grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
-	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
@@ -49,9 +59,11 @@ commit_version () # <hash>
 			sed "s,.\+,$t,"
 		done) |
 		head -n1)
-	if [ -z "$tag" ] ; then
-		# before -rc1 tag of release in progress
-		cat VERSION | cut -d'.' -f-2
+	if [ -z "$tag" ]; then
+		if [ "$branch" = 'HEAD' ]; then
+			# before -rc1 tag of release in progress
+			cat VERSION | cut -d'.' -f-2
+		fi
 	else
 		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
 	fi
Signature · 1 line
2.25.1
#16 lore raw

Re: [dpdk-stable] [PATCH v3 2/2] devtools: fix patches missing if range newer than HEAD

Someone to help with review of this patch please?
Is there a real need?

11/08/2021 13:22, Xueming Li:

Quoted 83 lines

Current fix scan scripts used HEAD branch as history reference. When users ran it in an earlier branch, few patches were scanned due to the fixes in the range are newer and not merged to current branch.

This patch introduces optional <branch> argument, default to HEAD if not specified. Checks the <range> specified in parameter must being merged in <branch>.

Fixes 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc Thomas Monjalon <[email protected]>
Cc Christian Ehrhardt <[email protected]>
---
 devtools/git-log-fixes.sh | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
devtools/git-log-fixes.sh +19 -7
index 153ba5b438..dbed4b6419 100755
@@ -4,7 +4,7 @@
 
 print_usage ()
 {
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"
 }
 
 print_help ()
@@ -15,6 +15,7 @@ print_help ()
 	Find fixes to backport on previous versions.
 	It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
 	The oldest bug origin is printed as well as partially fixed versions.
+	It looks into current branch or the branch specified.
 	END_OF_HELP
 }
 
@@ -33,14 +34,23 @@ while getopts h ARG ; do
 done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
-range="$*"
+range="$1"
+branch="$2"
+
+# default to current branch as history reference
+[ -n "$branch" ] || branch="HEAD"
+# get real brnach name
+refbranch=$(git rev-parse --abbrev-ref $branch)
+range_last=$(git rev-parse $range | head -n1)
+if ! git branch -a --contains $range_last | grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
-	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
@@ -49,9 +59,11 @@ commit_version () # <hash>
 			sed "s,.\+,$t,"
 		done) |
 		head -n1)
-	if [ -z "$tag" ] ; then
-		# before -rc1 tag of release in progress
-		cat VERSION | cut -d'.' -f-2
+	if [ -z "$tag" ]; then
+		if [ "$branch" = 'HEAD' ]; then
+			# before -rc1 tag of release in progress
+			cat VERSION | cut -d'.' -f-2
+		fi
 	else
 		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
 	fi
#17 lore raw

Re: [dpdk-stable] [PATCH v3 2/2] devtools: fix patches missing if range newer than HEAD

Quoted 4 lines · On Sat, 26 Nov 2022 22:44:26 +0100 Thomas Monjalon <[email protected]> wrote:

Someone to help with review of this patch please?
Is there a real need?

The patch looks ok, but no longer applies, needs to be rebased. Xueming if you are still needing this resubmit please.

Quoted 1 line
author
#18 lore raw

Re: [dpdk-stable] [PATCH v3 2/2] devtools: fix patches missing if range newer than HEAD

Not really needed, check out the main branch can avoid such issue. Thanks for looking into this.
________________________________
From: Stephen Hemminger <[email protected]>
Sent: Friday, August 16, 2024 12:32 AM
To: NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Christian Ehrhardt <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Xueming Li <[email protected]>
Subject: Re: [dpdk-stable] [PATCH v3 2/2] devtools: fix patches missing if range newer than HEAD

Quoted 4 lines · On Sat, 26 Nov 2022 22:44:26 +0100 Thomas Monjalon <[email protected]> wrote:

Someone to help with review of this patch please?
Is there a real need?

The patch looks ok, but no longer applies, needs to be rebased. Xueming if you are still needing this resubmit please.

Quoted 1 line