Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

1 vote
Answer 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 Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

185 views 1 3
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you