diff mbox series

[v1,2/2] devtools: auto detect branch to search fix patches

Message ID 20210616040324.311461-2-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series None | expand

Checks

Context Check Description
ci/iol-testing warning apply patch failure
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li June 16, 2021, 4:03 a.m. UTC
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 <thomas@monjalon.net>
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 devtools/check-git-log.sh |  2 +-
 devtools/git-log-fixes.sh | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index 9988bf863d..b463110a90 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -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:'
 
diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
index 5fc57da913..9d2d0ef96c 100755
--- a/devtools/git-log-fixes.sh
+++ b/devtools/git-log-fixes.sh
@@ -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