English 中文(简体)
How many people were involved in a project? Based on Revision Control System
原标题:

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?

最佳回答

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
问题回答

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.

For subversion

svn log -q svn://path/to/repo | cut -f 3 -d " "  | sort -u

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

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

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!

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}
  | 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}
  | sort -u

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

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




相关问题
Best practices for Subversion and Visual Studio projects

I ve recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that s built from a cobbling-together ...

Changing username in SVN+SSH URI on the fly in working copy

I am using SVN+SSH to check out a working copy of repository from an SVN server on which all developers are members of a developer group and have full read/write permissions on the repository ...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

How to search for file in subversion server?

Is there a way to search for a file in a subversion repository? Something similar to Unix find command, with which I can find the location of a file in a repository. I know there is svn list, but ...

热门标签