Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 10 | Comments: 37

filter by tags archive

Extracting a list of committers from Git

time to read 3 min | 518 words

There doesn’t seem to be a nice way to getting stats like “who are the committers in this project” from Git. There is probably some fancy script that does sed/awk magic to do so, but I went with a simpler alternative:

git log --raw > log.txt

var logFile = @"C:\work\ravendb\log.txt";

var committers = from line in File.ReadAllLines(logFile)
                 where line.StartsWith("Author: ")
                 let author = line.Substring("Author: ".Length)
                 group author by author
                 into g
                 let result = new {Committer = g.Key, CommitsCount = g.Count()}
                 orderby result.CommitsCount descending
                 select result;

foreach (var committer in committers)
{
    Console.WriteLine(committer);
}

Running this on Raven’s code produces:

{ Committer = Ayende Rahien <ayende>, CommitsCount = 555 }
{ Committer = Ayende Rahien <Ayende>, CommitsCount = 477 }
{ Committer = unknown <Ayende, CommitsCount = 72 }
{ Committer = Paul B <github, CommitsCount = 24 }
{ Committer = Andrew Stewart <Andrew.Stewart, CommitsCount = 24 }
{ Committer = Benny Thomas <jan.thomas, CommitsCount = 19 }
{ Committer = Luke Hertert <lukehertert, CommitsCount = 15 }
{ Committer = Bobby Johnson <bobby.johnson, CommitsCount = 13 }
{ Committer = Rob Ashton <robashton, CommitsCount = 11 }
{ Committer = unknown <LukeHertert, CommitsCount = 7 }
{ Committer = Andrew Theken <theken.1, CommitsCount = 6 }
{ Committer = AndyStewart <Andy.Stewart, CommitsCount = 3 }
{ Committer = Steve Strong <steve, CommitsCount = 3 }
{ Committer = unknown <Aaron Weiker, CommitsCount = 1 }
{ Committer = Emil Cardell <emil.cardell, CommitsCount = 1 }
{ Committer = bjarte.skogoy <bjarte.skogoy, CommitsCount = 1 }
{ Committer = unknown <henke, CommitsCount = 1 }


Comments

Martin Larsen

git log --raw | grep "^Author: " | sort | uniq -c

Masklinn

There doesn’t seem to be a nice way to getting stats like “who are the committers in this project” from Git.

The gitstat tool from the internets looks nice, considering git apparently doesn't have the equivalent of hg churn.

Frank Quednau

For completeness a powershell version that uses what is contained in the < and >:

git log --raw | Select-String -Pattern "^Author.<(.)>" | % { $_.Matches[

0].Groups[1].Value } | Group-Object | select count, name

Chris

+1 Larsen's solution

Ayende Rahien

Just one problem with all of the things that were suggested.

They requires me to THINK about those.

My solution was coded under heavy time pressure and I just needed the answers.

Going with the route of least resistance was the easiest and faster way to get things done.

Johannes Rudolph

That's why I couldn't live without linqPad anymore!

Martin Larsen

Ah... Cosmin 0wns us all. :-)

Marcin Floryan

Nice one, but how about streaming from a file? You'd be better off not having to read the whole file into memory which is precisely what LINQ allows you to do.

public IEnumerator

<string GetEnumerator()

    {

        using (TextReader reader = dataSource())

        {

            string line;

            while ((line = reader.ReadLine()) != null)

            {

                yield return line;

            }

        }

    }

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. Production postmortem: The case of the memory eater and high load - one day from now
  2. Production postmortem: The case of the lying configuration file - about one day from now
  3. Production postmortem: The industry at large - 3 days from now
  4. The insidious cost of allocations - 4 days from now
  5. Find the bug: The concurrent memory buster - 5 days from now

And 4 more posts are pending...

There are posts all the way to Sep 10, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    14 Aug 2015 - The case of the man in the middle
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats