5

How do you know how many developers were involved in a project using a Revision Control System? A friend of mine found this way to look up the answer in git log:

git log | grep Author: | sort -u | cut –delimiter=” ” -f2 | sort -u | wc -l

Is there a straightforward way in git? How about other Revision Control System like Subversion, Bazaar or Mercurial?

Juanjo Conti
  • 28,823
  • 42
  • 111
  • 133

7 Answers7

17

git

The shortlog command is very useful. This summarizes the typical git-log output.

$ git shortlog -sn
   119  tsaleh
   113  Joe Ferris
    70  Ryan McGeary
    45  Tammer Saleh
    45  Dan Croak
    19  Matt Jankowski
    ...

Pass to wc to see the number of unique usernames:

$ git shortlog -sn | wc -l
      40
Ryan McGeary
  • 235,892
  • 13
  • 95
  • 104
9

For mercurial, there's an extension to do exactly that: hg churn.

hg churn sorts by line-changed, if you want changeset count, use hg churn -c.

tonfa
  • 24,151
  • 2
  • 35
  • 41
4

For subversion

svn log -q svn://path/to/repo | cut -f 3 -d " "  | sort -u
epatel
  • 45,805
  • 17
  • 110
  • 144
2

There is stats plugin for Bazaar to get different info about project contributors:

https://launchpad.net/bzr-stats/

bialix
  • 20,053
  • 8
  • 46
  • 63
1

I'm not aware of a straightforward way for Mercurial either and a good search of all its documentation didn't revealed anything too. So, here's a *nix command, similar to the one your friend found, for Mercurial:

hg log | grep user: | cut -c 14- | sort -u | uniq | wc -l

BTW, I think there's an error with the command for git, the second sort -u should surely be replaced by uniq!

Nicolas Buduroi
  • 3,565
  • 1
  • 28
  • 29
  • @Charles Bailey: Look again, it's done two times! @tonfa: Didn't knew about that one, should look at extensions more closely. – Nicolas Buduroi Nov 29 '09 at 05:06
  • I agree, the first `sort -u` is redundant in the question, but still, I don't see anything wrong with it. But you also pipe the output of `sort -u` to `uniq` so I was wondering what you made you not trust `sort -u`? – CB Bailey Dec 05 '09 at 11:03
  • Oh! My fault didn't knew about the -u option! – Nicolas Buduroi Dec 05 '09 at 17:29
1

Mercurial has a powerful template language built-in (see hg help templates). So you can get a list of all people in the project without enabling the churn extension:

hg log --template '{author}\n' | sort -u

If people have changed their email address (but otherwise kept their name the same), then you can process the author template keyword a bit:

hg log --template '{author|person}\n' | sort -u

Then add wc -l as appropriate to the above commands.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
0

A simpler git version is:

git log --pretty=tformat:%an | sort -u | wc -l

or if you care about unique email addresses:

git log --pretty=tformat:%ae | sort -u | wc -l
CB Bailey
  • 755,051
  • 104
  • 632
  • 656