[dpdk-dev] devtools: fix version search with git < 2.7.0

Message ID 20170904220532.10175-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Thomas Monjalon Sept. 4, 2017, 10:05 p.m. UTC
  The script git-log-fixes.sh (used in check-git-log.sh) looks
for git tags to find the version where a bug is introduced.

In DPDK 17.08, the script has been fixed to ignore tags from
non current branch.
It was using the option --merged which was introduced in git 2.7.0.

As git 2.7.0 is not so old, a fallback is provided for some years.

The fallback is replacing the tag --merged option by a branch filter.
If the tag is found in the branch, the branch name is replaced
by the tag.

This script could be improved to allow using another reference branch,
instead of hard coding HEAD branch (the current one).

Fixes: 26857dabb3c9 ("devtools: ignore non merged tags for backport")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 devtools/git-log-fixes.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Comments

Nélio Laranjeiro Sept. 15, 2017, 9:24 a.m. UTC | #1
On Tue, Sep 05, 2017 at 12:05:32AM +0200, Thomas Monjalon wrote:
> The script git-log-fixes.sh (used in check-git-log.sh) looks
> for git tags to find the version where a bug is introduced.
> 
> In DPDK 17.08, the script has been fixed to ignore tags from
> non current branch.
> It was using the option --merged which was introduced in git 2.7.0.
> 
> As git 2.7.0 is not so old, a fallback is provided for some years.
> 
> The fallback is replacing the tag --merged option by a branch filter.
> If the tag is found in the branch, the branch name is replaced
> by the tag.
> 
> This script could be improved to allow using another reference branch,
> instead of hard coding HEAD branch (the current one).
> 
> Fixes: 26857dabb3c9 ("devtools: ignore non merged tags for backport")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Solves the issue.
  
Thomas Monjalon Sept. 22, 2017, 1:41 p.m. UTC | #2
15/09/2017 11:24, Nélio Laranjeiro:
> On Tue, Sep 05, 2017 at 12:05:32AM +0200, Thomas Monjalon wrote:
> > The script git-log-fixes.sh (used in check-git-log.sh) looks
> > for git tags to find the version where a bug is introduced.
> > 
> > In DPDK 17.08, the script has been fixed to ignore tags from
> > non current branch.
> > It was using the option --merged which was introduced in git 2.7.0.
> > 
> > As git 2.7.0 is not so old, a fallback is provided for some years.
> > 
> > The fallback is replacing the tag --merged option by a branch filter.
> > If the tag is found in the branch, the branch name is replaced
> > by the tag.
> > 
> > This script could be improved to allow using another reference branch,
> > instead of hard coding HEAD branch (the current one).
> > 
> > Fixes: 26857dabb3c9 ("devtools: ignore non merged tags for backport")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 
> Solves the issue.

Applied
  

Patch

diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
index 580068741..cd5cf8939 100755
--- a/devtools/git-log-fixes.sh
+++ b/devtools/git-log-fixes.sh
@@ -66,7 +66,16 @@  range="$*"
 # get major release version of a commit
 commit_version () # <hash>
 {
-	tag=$(git tag -l --contains $1 --merged | head -n1)
+	# use current branch as history reference
+	local refbranch=$(git rev-parse --abbrev-ref HEAD)
+	local tag=$( (git tag -l --contains $1 --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
+			git branch $refbranch --contains $t |
+			sed "s,.\+,$t,"
+		done) |
+		head -n1)
 	if [ -z "$tag" ] ; then
 		# before -rc1 tag of release in progress
 		make showversion | cut -d'.' -f-2