From: Felipe Contreras Date: Sat, 18 May 2013 11:46:52 GMT Subject: [PATCH v5 12/15] contrib: related: add option to show commits Message-ID: <1368877615-9563-13-git-send-email-felipe.contreras@gmail.com> In-Reply-To: <1368877615-9563-1-git-send-email-felipe.contreras@gmail.com> Instead of showing the authors and signers, show the commits themselves. Signed-off-by: Felipe Contreras --- contrib/related/git-related | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/related/git-related b/contrib/related/git-related index a2f98d9..aec156e 100755 --- a/contrib/related/git-related +++ b/contrib/related/git-related @@ -7,6 +7,7 @@ require 'optparse' $since = '5-years-ago' $min_percent = 10 +$show_commits = false $mailmaps = {} $mailmaps_complex = {} @@ -22,6 +23,9 @@ begin opts.on('-d', '--since DATE', 'How far back to search for relevant commits') do |v| $since = v end + opts.on('-c', '--commits[=FORMAT]', [:raw, :full], 'List commits instead of persons') do |v| + $show_commits = v || true + end end.parse! rescue OptionParser::InvalidOption end @@ -167,6 +171,10 @@ class Commits @items.each(&block) end + def list + @items.keys + end + def import return if @items.empty? File.popen(%w[git cat-file --batch], 'r+') do |p| @@ -226,6 +234,20 @@ commits = Commits.new commits.from_patches(ARGV) commits.import +if $show_commits + cmd = nil + case $show_commits + when :raw + puts commits.list + when :full + cmd = %w[git log --patch --no-walk] + else + cmd = %w[git log --oneline --no-walk] + end + system(*cmd + commits.list) if cmd + exit 0 +end + persons = Persons.new persons.sort.reverse.each do |person| -- 1.8.3.rc2.542.g24820ba