0

Is there a ruby gem to display the total commits made by a user in terminal ? And also to show the output in terms of pie chart on UI ?

Sap
  • 235
  • 1
  • 15

1 Answers1

1

Rugged gem has a way to do it.

require 'rugged'
repo = Rugged::Repository.new('git-project-dir')
walker = Rugged::Walker.new(repo)
walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
walker.push(repo.head.target)
walker.count { |c| c.author[:email] == "<user_email>" }

=> 52 

Without using any gem, a shell command from your git repo directory can get you the total number of commits for an user:

`git shortlog -s -n --all| grep <user> | cut -f1`
Raj
  • 22,346
  • 14
  • 99
  • 142
  • 1
    I want to do it using gem, there is a rubygem to count commits and displays the content using pie chart. – Sap Apr 15 '14 at 11:48
  • Thanks for your answer, but it'll be good if you could tell any other gem's name. – Sap Apr 15 '14 at 12:39
  • you can achieve the same using Rugged. check my updated answer. – Raj Apr 15 '14 at 13:08