[PATCH v3 10/11] contrib: cc-cmd: sort by participation
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/cc-cmd/git-cc-cmd | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/cc-cmd/git-cc-cmd b/contrib/cc-cmd/git-cc-cmd
index 67a276d..9a2d2fd 100755
--- a/contrib/cc-cmd/git-cc-cmd
+++ b/contrib/cc-cmd/git-cc-cmd
@@ -237,7 +237,12 @@ commits.items.values.each do |commit|
end
end
-persons.each do |person, roles|
+# sort by number of participations
+count_sort = lambda do |a, b|
+ b[1].values.reduce(:+) <=> a[1].values.reduce(:+)
+end
+
+persons.sort(&count_sort).each do |person, roles|
roles = roles.map do |role, count|
percent = count.to_f * 100 / commits.size
next if percent < $min_percent
--
1.8.2.1.790.g4588561