[PATCH v10 14/15] contrib: related: add option to show commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of showing the authors and signers, show the commits themselves.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 contrib/related/git-related    | 23 +++++++++++++++++++++++
 contrib/related/test-related.t | 10 ++++++++++
 2 files changed, 33 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index d6b44c7..b9c8619 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -7,6 +7,7 @@ $since = '5-years-ago'
 $min_percent = 10
 $files = []
 $rev_args = []
+$show_commits = false
 
 $mailmaps = {}
 $mailmaps_complex = {}
@@ -128,6 +129,10 @@ opts.on('d', 'since', 'How far back to search for relevant commits') do |v|
   $since = v
 end
 
+opts.on('c', 'commits', 'List commits instead of persons') do |v|
+  $show_commits = v
+end
+
 opts.parse
 
 class Person
@@ -238,6 +243,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|
@@ -339,6 +348,20 @@ else
 end
 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|
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index fa8c1a7..f357e30 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -94,4 +94,14 @@ test_expect_success "mailmap" "
 	test_cmp expected actual
 "
 
+test_expect_success "commits" "
+	git related -craw -1 master | git log --format='%s' --no-walk --stdin > actual &&
+	cat > expected <<-EOF &&
+	four
+	three
+	one
+	EOF
+	test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]