Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Code statistics of specific branch for current week

sschuberth February 25, 2014

I just started using Crucible / FishEye on top of a Git repository. To get a feeling how much our code base is in a state of flux, for a specific branch, I'd like to see the amount of code changes (lines added / removed) in relation to the total lines of code for the last 7 days / the current week. I tried to come up with something using EyeQL but failed miserably at even getting the syntax right (I always get "unexpected token: thisweek" no matter how I try to use the "thisweek" keyword). Any hint how this could be accomplished? Does FishEye even know about the total lines of code, as I guess this is something specific to the programming language?

2 answers

1 accepted

1 vote
Answer accepted
sschuberth February 27, 2014

Hi Sten,

thanks for the response. Getting the total number of lines (per file type) is crucial for our stats to get some meaning. However, it actually turned out to be quite easy to get the stats I need in plain Git. The idea is to simply get the diff to the "empty commit", which equals the lines of currently committed code. At the example of Java files my shell script looks like this:

empty=$(git hash-object -t tree /dev/null)
total=$(git diff --stat $empty -- *.java | tail -1 | cut -d "," -f 2 | cut -d " " -f 2)
echo "Total lines of Java code in repository: $total"

Next, I get the amount of changed code since the last 7 days like this:

stats=$(git log --since=1.week --pretty=tformat: --numstat -- *.java | awk '{ added += $1 ; removed += $2 } END { printf "%s,%s",added,removed }' -)
added=$(echo $stats | cut -d "," -f 1)
removed=$(echo $stats | cut -d "," -f 2)
changed=$(expr $added + $removed)
echo "Java statistics for the last 7 days: $added lines added, $removed lines removed, $changed lines changed"

With these numbers it's now easy to come up with a change ratio which sort of reflects how much the code base is in flux.

Given that this was not too hard at all, I hope FishEye will soon be able to support LOC stats for Git repositories, too ;-)

0 votes
Sten Pittet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2014

Hi Sebastian,

Unfortunately FishEye does not provide Lines of Code statistic for Git as this is something quite complex to build of Git repositories. We're looking into alternatives and I'd like to get your feedback.

Would you be happy to simply see a volume of changes other time without the ratio to the total line of code count?

Sten Pittet
Dev Tools Product Manager

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events