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

Message ID 20210612135628.20460-2-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Headers
Series [1/2] devtools: fix version pattern for fix search |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot success github build: passed
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing fail Testing issues
ci/intel-Testing success Testing PASS

Commit Message

Xueming Li June 12, 2021, 1:56 p.m. UTC
  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 <thomas@monjalon.net>
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 devtools/git-log-fixes.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Christian Ehrhardt June 14, 2021, 2:15 p.m. UTC | #1
On Sat, Jun 12, 2021 at 3:57 PM Xueming Li <xuemingl@nvidia.com> wrote:
>
> 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)

> scanned.
>
> This patch auto etects branch to scan from range.

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

>
> 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/git-log-fixes.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
> index 5fc57da913..9a8a9d6739 100755
> --- a/devtools/git-log-fixes.sh
> +++ b/devtools/git-log-fixes.sh
> @@ -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.

> +# 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
>
  
Xueming Li June 15, 2021, 10:56 a.m. UTC | #2
> -----Original Message-----
> From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Sent: Monday, June 14, 2021 10:16 PM
> To: Xueming(Steven) Li <xuemingl@nvidia.com>
> Cc: dev <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; dpdk stable
> <stable@dpdk.org>; Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Subject: Re: [PATCH 2/2] devtools: auto detect branch to search fix patches
> 
> On Sat, Jun 12, 2021 at 3:57 PM Xueming Li <xuemingl@nvidia.com> wrote:
> >
> > 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)
> 
> > scanned.
> >
> > This patch auto etects branch to scan from range.
> 
> ^^ typo missing "d" (if you care)

Thanks :)

> 
> >
> > 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/git-log-fixes.sh | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
> > index 5fc57da913..9a8a9d6739 100755
> > --- a/devtools/git-log-fixes.sh
> > +++ b/devtools/git-log-fixes.sh
> > @@ -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.

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"
 
> 
> > +# 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
> >
> 
> 
> --
> Christian Ehrhardt
> Staff Engineer, Ubuntu Server
> Canonical Ltd
  
Xueming Li June 30, 2021, 6:46 a.m. UTC | #3
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Xueming(Steven) Li
> Sent: Tuesday, June 15, 2021 6:56 PM
> To: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Cc: dev <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; dpdk stable
> <stable@dpdk.org>; Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Subject: Re: [dpdk-dev] [PATCH 2/2] devtools: auto detect branch to search fix patches
> 
> 
> 
> > -----Original Message-----
> > From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> > Sent: Monday, June 14, 2021 10:16 PM
> > To: Xueming(Steven) Li <xuemingl@nvidia.com>
> > Cc: dev <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>;
> > NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; dpdk stable
> > <stable@dpdk.org>; Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > Subject: Re: [PATCH 2/2] devtools: auto detect branch to search fix
> > patches
> >
> > On Sat, Jun 12, 2021 at 3:57 PM Xueming Li <xuemingl@nvidia.com> wrote:
> > >
> > > 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)
> >
> > > scanned.
> > >
> > > This patch auto etects branch to scan from range.
> >
> > ^^ typo missing "d" (if you care)
> 
> Thanks :)
> 
> >
> > >
> > > 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/git-log-fixes.sh | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
> > > index 5fc57da913..9a8a9d6739 100755
> > > --- a/devtools/git-log-fixes.sh
> > > +++ b/devtools/git-log-fixes.sh
> > > @@ -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.
> 
> 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

> 
> >
> > > +# 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
> > >
> >
> >
> > --
> > Christian Ehrhardt
> > Staff Engineer, Ubuntu Server
> > Canonical Ltd
  

Patch

diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
index 5fc57da913..9a8a9d6739 100755
--- a/devtools/git-log-fixes.sh
+++ b/devtools/git-log-fixes.sh
@@ -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