[PATCH] get_authors.sh, author.rb: use -s option of git shortlog.
From: Adeodato Simó <hidden>
Date: 2016-06-15 22:45:52
Subsystem:
the rest · Maintainer:
Linus Torvalds
Suggested by Miklos Vajna [off-list ref]. --- app/models/author.rb | 26 ++++++++++++-------------- script/get_authors.sh | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-)
I suppose fixing up the ruby part after this is not that hard, sadly I don't speak Ruby myself, so I have no idea where and what to touch. ;-)
Done. Btw, I don't think authors.txt should be in the repo at all, since it's automatically generated, but it's your choice. :-)
diff --git a/app/models/author.rb b/app/models/author.rb
index 8fafc15..6bf069a 100644
--- a/app/models/author.rb
+++ b/app/models/author.rb@@ -1,22 +1,20 @@ class Author - - def self.all - authors = File.join(RAILS_ROOT, 'config/authors.txt') + def self.all + authors = File.join(RAILS_ROOT, 'config/authors.txt') if File.exists?(authors) authors = File.readlines(authors) @authors = {:main => [], :contrib => []} authors.each do |author| - data = author.split(' ') - number = data.pop.gsub('(', '').gsub(')', '').chomp - name = data.join(' ') - if(number.to_i > 50) - @authors[:main] << [name, number.to_i] - else - @authors[:contrib] << [name, number.to_i] + if author =~ /(\d+)\s+(.+)/ + name, number = $2, $1.to_i + if number > 50 + @authors[:main] << [name, number] + else + @authors[:contrib] << [name, number] + end end end + @authors end - @authors - end - -end
\ No newline at end of file + end +end
diff --git a/script/get_authors.sh b/script/get_authors.sh
index 9aa8c6b..028a354 100755
--- a/script/get_authors.sh
+++ b/script/get_authors.sh@@ -1,3 +1,3 @@ export GIT_DIR=/Users/schacon/projects/git/.git cd /Users/schacon/projects/git -git log --pretty=short --no-merges | git shortlog -n | grep -v -e '^ ' | grep ':' > ../gitscm/config/authors.txt +git shortlog --no-merges -sn > ../gitscm/config/authors.txt
--
1.6.1.62.g677ca