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

This widget could not be displayed.

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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

97 views 1 0
Join discussion

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