Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need to fetch lines of code of a bitbucket repository using any available API and python

kompal.sithta May 22, 2023

Hi All,

 

We are trying to fetch the lines of code from a bitbucket repository using python and any API available.

 

Till now we have tried to seek help from the following blog post - https://stiltsoft.com/blog/how-to-count-lines-of-code-in-bitbucket-to-decide-what-sonarqube-license-you-need/ but we are facing errors while establishing the connection.

 

Is there any method, api, documentation from where we can fetch this data?

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 23, 2023

Hello @kompal.sithta and thank you for reaching out to the community!

I'm afraid that currently Bitbucket Cloud does not have a built-in feature to track code statistics, like the number of lines of code in a workspace or repository, so we don't currently have an API for that particular operation. We do have an open feature request to implement this functionality, which you can access with the link below : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

While this feature is not available, you have the option to clone the repository locally and use the following git command to get the total number of lines per repository file : 

git ls-files | xargs wc -l
      50 .gitignore
      44 README.md
       1 fileA.txt
       1 fileB.txt
       2 fileD.txt
      98 total

Alternatively, you can also check out for available code reviews add-ons in Bitbucket's Marketplace : 

Thank you, @kompal.sithta !
Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events