Im trying to send a report which contains Count of commits done by developers everyday in git repository.
#read all the inputs
read -p "Enter the Branch Name:" branchname
read -p "Enter the from date:" frmdate
read -p "Enter the To date:" todate
#execute the command to get the commit history
git log origin/$branchname --name-status --pretty=format:"%cn committed %h on %cd full" --after="$frmdate 00:00" --before="$todate 23:59" --decorate | git shortlog -s -n > history.txt
This script help me to create a file which contains what are the files changed and by whom on a given date. But i need the count of commits made by indvidual devlopers.
I tried with git shortlog -s -n
, It gives the overall commit count by developer in all branches.
Need to create a report to get the commit count of each developer in a daily basis
To get the number of commits for each user execute git shortlog -sn --all. To get the number of lines added and delete by a specific user install q and then execute: git log --author="authorsname" --format=tformat: --numstat | q -t "select sum(c1), sum(c2) from -"
On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
The git shortlog command is a special version of git log intended for creating release announcements. It groups each commit by author and displays the first line of each commit message.
Well.... what I would do is:
It would be something like:
the_date=$( date +%F )
git log --pretty="%ae" --since=yesterday the-branch | sort | uniq | while read author; do
git log --author=$author --since-yesterday the-branch > "$the_date"_"$author".txt
done
If you need more information (like the files that were changed and so on, just add more options to the log call inside the while cycle.
Try this in one line (as one command):
git log --pretty="%cd %aE" --date='format:%Y-%m-%d' BRANCH |
sort -r |
uniq -c |
grep AUTHOR_YOU_ARE_INTERESTED_IN
Example output:
1 2017-05-10 [email protected]
2 2017-04-13 [email protected]
1 2017-03-30 [email protected]
1 2017-03-03 [email protected]
2 2017-01-24 [email protected]
1 2016-12-14 [email protected]
1 2016-11-23 [email protected]
1 2016-11-21 [email protected]
1 2016-11-18 [email protected]
3 2016-11-16 [email protected]
Missing dates in the report imply no commits for that person on that branch on the missing dates.
The number on the far left (1, 2, 1, 1, etc...) is the # of commits that author had committed on that day.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With