contributor
contributor copied to clipboard
[Feature/Request] Generic GIT repository parser
This plugin is great and has me wishing the project that I am on is using GitHub instead of Stash. So I started thinking about how we could achieve this same functionality using just standard git
commands.
Here is what I have come up with:
This command will return the stats for the specified author
.
- Adding the
--perl-regexp
flag allows you to specify aperl regexp
to the authors like so:mstramel|stramel
orMichael Stramel|stramel|mstramel
- Adding the
grep -v
will remove the specified paths from the statistics - Adding the
--all
flag allows you to grab commits from all branches
$ git log --author="mstramel|stramel" --perl-regexp --all --pretty=tformat: --numstat | \
grep -v docs | \
gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END \
{ printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
To handle author inconsistencies, I created a author map if you will. You can find these inconsistencies by running:
$ git shortlog -se
- The
key
should be the proper name that will be used - The
value
should be the regexp to match the authors too.
// .authors.json
{
"Michael Stramel": "Michael Stramel|stramel|mstramel"
}
By iterating over each author you can run it through the git log
command to generate all the statistics. Would love to see this functionality bundled into this project. Let me know your thoughts! :+1:
Resources: http://jonrohan.me/guide/git/list-git-contributors/ http://git-scm.com/docs/git-shortlog http://codeimpossible.com/2011/12/16/Stupid-Git-Trick-getting-contributor-stats/ http://git-scm.com/docs/git-log