Code statistics of specific branch for current week

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

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 ;-)

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 Join to answer
Community showcase
Bridget Sauer
Published Mar 09, 2018 in Jira Service Desk

E.L. Fridge's take on education, Jira Service Desk, and creative Jira use cases

...word of mouth, so by 2016, we were working with several other entities on campus to implement Jira Service Desk . The Atlassian motto of “for every team” has really come true for us in this case. We...

322 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot