Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to count total Line of Code LOC in Bitbucket Repo

Azfar_Masut
Contributor
April 10, 2018

How to count the total LOC in Bitbucket's repo bare-repo?

1 answer

1 vote
Azfar_Masut
Contributor
April 10, 2018 edited
#!/bin/bash

targetPath=/data/atlassian/bitbucket-data/shared/data/repositories/
temp=0
total=0
filename=branch_count.log
log=$targetPath/$filename
echo "Script Start -- $(date +%Y%m%d_%H%M)" >> $log

for f in `find $targetPath -maxdepth 1 -type d`;
do
cd $f
pwd | tee -a $log
for file in $(git ls-tree --name-only -r HEAD);
do
temp=`git show HEAD:"$file" | grep -v ^\# | wc -l`
total=$(($total + $temp))
echo $temp | tee -a $log
done
done

echo "Script End -- Total Branch in all Repo:$total" | tee -a $log

 Sorry about the messy scripts. Rather amateur and in rush!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, forge, forge learning path, atlassian learning, cloud app development, forge app development, build forge apps, atlassian certification, developer training, jira app development, confluence app development, automation, ui frameworks

Turn Ideas into Atlassian Apps 📱

From setup to deployment—this learning path shows you how to build your first app using Forge. Learn the essentials, streamline workflows, and bring custom solutions to life across Jira, Confluence, and more.

Start Learning
AUG Leaders

Atlassian Community Events