DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] scripts: show fixes with release version of bug
@ 2016-09-29  9:41 Thomas Monjalon
  2016-09-30 14:18 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2016-09-29  9:41 UTC (permalink / raw)
  To: dev; +Cc: Yuanhan Liu

This script can help to find commits to backport in stable branches.

Fixes are found if there is the word "fix" in the headline or
if there is a tag Fixes: or Reverts: in the message.
Chained fixes of fixes are explored to find the oldest origin.
Fixes of not released bugs are ignored.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 scripts/git-log-fixes.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100755 scripts/git-log-fixes.sh

diff --git a/scripts/git-log-fixes.sh b/scripts/git-log-fixes.sh
new file mode 100755
index 0000000..cb7ed2e
--- /dev/null
+++ b/scripts/git-log-fixes.sh
@@ -0,0 +1,63 @@
+#! /bin/sh -e
+
+if [ $# -lt 1 ] ; then
+	echo 'range argument required' >&2
+	exit 1
+fi
+range="$*"
+
+# get major release version of a commit
+commit_version () # <hash>
+{
+	tag=$(git tag -l --contains $1 | head -n1)
+	if [ -z "$tag" ] ; then
+		# before -rc1 tag of release in progress
+		make showversion | cut -d'.' -f-2
+	else
+		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
+	fi
+}
+
+# get bug origin hashes of a fix
+origin_filter () # <hash>
+{
+	git log --format='%b' -1 $1 |
+	sed -n 's,^ *\([Ff]ixes\|[Rr]everts\): *\([0-9a-f]*\).*,\2,p'
+}
+
+# get oldest major release version of bug origins
+origin_version () # <origin_hash> ...
+{
+	for origin in $* ; do
+		# check hash is valid
+		git rev-parse -q --verify $1 >&- || continue
+		# get version of this bug origin
+		local origver=$(commit_version $origin)
+		local roothashes=$(origin_filter $origin)
+		if [ -n "$roothashes" ] ; then
+			# look chained fix of fix recursively
+			local rootver="$(origin_version $roothashes)"
+			[ -n "$rootver" ] || continue
+			echo "$rootver (partially fixed in $origver)"
+		else
+			echo "$origver"
+		fi
+	# filter the oldest origin
+	done | sort -uV | head -n1
+}
+
+git log --oneline --reverse $range |
+while read id headline ; do
+	origins=$(origin_filter $id)
+	[ -n "$origins" ] || echo "$headline" | grep -q fix || continue
+	version=$(commit_version $id)
+	if [ -n "$origins" ] ; then
+		origver="$(origin_version $origins)"
+		[ -n "$origver" ] || continue
+		# ignore fix of bug introduced in the same release
+		! echo "$origver" | grep -q "^$version" || continue
+	else
+		origver='N/A'
+	fi
+	printf '%s %7s %s (%s)\n' $version $id "$headline" "$origver"
+done
-- 
2.7.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-05 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29  9:41 [dpdk-dev] [PATCH] scripts: show fixes with release version of bug Thomas Monjalon
2016-09-30 14:18 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2016-11-04  6:58   ` Yuanhan Liu
2016-11-05 14:49     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).