[v3,2/2] devtools: fix patches missing if range newer than HEAD
Checks
Commit Message
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 <thomas@monjalon.net>
Cc: stable@dpdk.org
Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
devtools/git-log-fixes.sh | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
Comments
Someone to help with review of this patch please?
Is there a real need?
11/08/2021 13:22, Xueming Li:
> 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 <thomas@monjalon.net>
> Cc: stable@dpdk.org
> Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
> devtools/git-log-fixes.sh | 26 +++++++++++++++++++-------
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
> index 153ba5b438..dbed4b6419 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 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
>
On Sat, 26 Nov 2022 22:44:26 +0100
Thomas Monjalon <thomas@monjalon.net> 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.
>
Not really needed, check out the main branch can avoid such issue. Thanks for looking into this.
@@ -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