public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] egencache --update-changelogs: filter merge commit noise (bug 579402)
@ 2016-04-09  9:07 Zac Medico
  2016-04-09 20:22 ` Brian Dolbec
  0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2016-04-09  9:07 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

In order to filter out merge commit noise, pass the -m and --first-parent
options to the git commands. According to the description of these options
in the git-log man page, "the output represents the changes the merge
brought into the then-current branch".

Suggested-by: Doug Freed <dwfreed@mtu.edu>
X-Gentoo-bug: 579402
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=579402
---
 bin/egencache | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 0123d57..9da7103 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -735,6 +735,9 @@ class _special_filename(_filename_base):
 			return self.file_name < other.file_name
 
 class GenChangeLogs(object):
+
+	_GIT_LOG_OPTS = ('-m', '--first-parent')
+
 	def __init__(self, portdb, changelog_output, changelog_reversed,
 		max_jobs=None, max_load=None):
 		self.returncode = os.EX_OK
@@ -770,7 +773,8 @@ class GenChangeLogs(object):
 		os.chdir(os.path.join(self._repo_path, cp))
 		# Determine whether ChangeLog is up-to-date by comparing
 		# the newest commit timestamp with the ChangeLog timestamp.
-		lmod = self.grab(['git', self._work_tree, 'log', '--format=%ct', '-1', '.'])
+		lmod = self.grab(['git', self._work_tree, 'log']
+			+ list(self._GIT_LOG_OPTS) + ['--format=%ct', '-1', '.'])
 		if not lmod:
 			# This cp has not been added to the repo.
 			return
@@ -802,7 +806,8 @@ class GenChangeLogs(object):
 			''' % (cp, time.strftime('%Y'))))
 
 		# now grab all the commits
-		revlist_cmd = ['git', self._work_tree, 'rev-list']
+		revlist_cmd = ['git', self._work_tree, 'rev-list'
+			] + list(self._GIT_LOG_OPTS)
 		if self._changelog_reversed:
 			revlist_cmd.append('--reverse')
 		revlist_cmd.extend(['HEAD', '--', '.'])
@@ -810,6 +815,7 @@ class GenChangeLogs(object):
 
 		for c in commits:
 			# Explaining the arguments:
+			# -m --first-parent filters merge commit noise (`man git-log`)
 			# --name-status to get a list of added/removed files
 			# --no-renames to avoid getting more complex records on the list
 			# --format to get the timestamp, author and commit description
@@ -818,7 +824,8 @@ class GenChangeLogs(object):
 			# -r (recursive) to get per-file changes
 			# then the commit-id and path.
 
-			cinfo = self.grab(['git', self._work_tree, 'diff-tree',
+			cinfo = self.grab(['git', self._work_tree, 'diff-tree']
+					+ list(self._GIT_LOG_OPTS) + [
 					'--name-status',
 					'--no-renames',
 					'--format=%ct %cN <%cE>%n%B',
-- 
2.7.4



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

* Re: [gentoo-portage-dev] [PATCH] egencache --update-changelogs: filter merge commit noise (bug 579402)
  2016-04-09  9:07 [gentoo-portage-dev] [PATCH] egencache --update-changelogs: filter merge commit noise (bug 579402) Zac Medico
@ 2016-04-09 20:22 ` Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-04-09 20:22 UTC (permalink / raw
  To: gentoo-portage-dev

On Sat,  9 Apr 2016 02:07:31 -0700
Zac Medico <zmedico@gentoo.org> wrote:

> In order to filter out merge commit noise, pass the -m and
> --first-parent options to the git commands. According to the
> description of these options in the git-log man page, "the output
> represents the changes the merge brought into the then-current
> branch".
> 
> Suggested-by: Doug Freed <dwfreed@mtu.edu>
> X-Gentoo-bug: 579402
> X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=579402
> ---
>  bin/egencache | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/bin/egencache b/bin/egencache
> index 0123d57..9da7103 100755
> --- a/bin/egencache
> +++ b/bin/egencache
> @@ -735,6 +735,9 @@ class _special_filename(_filename_base):
>  			return self.file_name < other.file_name
>  
>  class GenChangeLogs(object):
> +
> +	_GIT_LOG_OPTS = ('-m', '--first-parent')
> +
>  	def __init__(self, portdb, changelog_output,
> changelog_reversed, max_jobs=None, max_load=None):
>  		self.returncode = os.EX_OK
> @@ -770,7 +773,8 @@ class GenChangeLogs(object):
>  		os.chdir(os.path.join(self._repo_path, cp))
>  		# Determine whether ChangeLog is up-to-date by
> comparing # the newest commit timestamp with the ChangeLog timestamp.
> -		lmod = self.grab(['git', self._work_tree, 'log',
> '--format=%ct', '-1', '.'])
> +		lmod = self.grab(['git', self._work_tree, 'log']
> +			+ list(self._GIT_LOG_OPTS) +
> ['--format=%ct', '-1', '.']) if not lmod:
>  			# This cp has not been added to the repo.
>  			return
> @@ -802,7 +806,8 @@ class GenChangeLogs(object):
>  			''' % (cp, time.strftime('%Y'))))
>  
>  		# now grab all the commits
> -		revlist_cmd = ['git', self._work_tree, 'rev-list']
> +		revlist_cmd = ['git', self._work_tree, 'rev-list'
> +			] + list(self._GIT_LOG_OPTS)
>  		if self._changelog_reversed:
>  			revlist_cmd.append('--reverse')
>  		revlist_cmd.extend(['HEAD', '--', '.'])
> @@ -810,6 +815,7 @@ class GenChangeLogs(object):
>  
>  		for c in commits:
>  			# Explaining the arguments:
> +			# -m --first-parent filters merge commit
> noise (`man git-log`) # --name-status to get a list of added/removed
> files # --no-renames to avoid getting more complex records on the list
>  			# --format to get the timestamp, author and
> commit description @@ -818,7 +824,8 @@ class GenChangeLogs(object):
>  			# -r (recursive) to get per-file changes
>  			# then the commit-id and path.
>  
> -			cinfo = self.grab(['git', self._work_tree,
> 'diff-tree',
> +			cinfo = self.grab(['git', self._work_tree,
> 'diff-tree']
> +					+ list(self._GIT_LOG_OPTS) +
> [ '--name-status',
>  					'--no-renames',
>  					'--format=%ct %cN <%cE>%n%B',

It looks good to me, but I'd like to hear from Doug first, just to be
sure...

-- 
Brian Dolbec <dolsen>



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

end of thread, other threads:[~2016-04-09 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-09  9:07 [gentoo-portage-dev] [PATCH] egencache --update-changelogs: filter merge commit noise (bug 579402) Zac Medico
2016-04-09 20:22 ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox