Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT Weekly Activity

I would like to generate a weekly GIT report, where I can see how many code has been submitted and deleted by each developer in specific timeframe.

The purpose is to get general overview of developers activity in specific timeframe

  • Start date
  • End date
  • Developer
  • Commits
  • Added code
  • Deleted code

It would be great if I can export these information into csv

[some-script/command] > weekly-git-log.csv
like image 950
Pavel Binar Avatar asked Nov 25 '12 02:11

Pavel Binar


2 Answers

I'd start with git log --since="1 week ago" --until="now" and customize it to your heart's content.

Example:

git log --since="1 week ago" --until="now" --format="%an,%ct,%s" > weekly-git-log.csv

You aren't being very specific about what you want to store in the CSV file, so I'm giving you a very general answer and letting you fill in the details yourself.

EDIT:

If you want to get lines added/removed, you're going to have to get a bit fancier and use a bash script:

#!/bin/bash
IFS=$'\n'
DATA=(`git log --since="1 week ago" --until="now" --format="%ct,%an,%s,"`)
LINES=(`git log --since="1 week ago" --until="now" --pretty=tformat: --shortstat | gawk '(NF > 0){ printf "%s,%s\n",$1,$4 }' -`)

i=0
while [ $i -lt ${#DATA[@]} ]; do
    echo "${DATA[$i]}${LINES[$i]}"
    i=$[i + 1]
done

I'm throwing in lines added/removed after the message, since it's easier to do in the script (I'm not THAT great with bash). This should be a pretty good foundation for what you want to do. (call ./script.sh >file.csv to output to a file)

Note that commas in the commit message will break your csv file, I'd change the commas in the --format to some obscure character that can't be regularly typed on a keyboard, scrub out any commas in the message, then substitute commas for that obscure character.

Or you can just do away with %s in the format too if you don't need the message.

like image 112
Robert Rouhani Avatar answered Sep 24 '22 00:09

Robert Rouhani


List of changes for specific user in specific date range - Each file details

git log --pretty=format:"%h,%an,%ad,%s" [email protected] --since=2012-11-19 --until=2012-11-20 --date=short --numstat

List of changes for specific user in specific date range - Commit summary

git log --pretty=format:"%h,%an,%ad,%s" [email protected] --since=2012-11-19 --until=2012-11-20 --date=short --shortstat

Final short version

git log --pretty=format:"%Cgreen%ad%x09%Cblue%s" --date=short [email protected] --shortstat --since=2012-11-19 --until=2012-11-20
like image 40
Pavel Binar Avatar answered Sep 26 '22 00:09

Pavel Binar