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
#!/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
AUG Leaders

Atlassian Community Events