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?
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
I am Vlada from the Awesome Graphs for Bitbucket team and I wanted to share that the article you are reading refers to Bitbucket Data Center instances. You are using Cloud, right?
Could you possibly describe your use case in more detail? I would love to record your request in our backlog for Cloud features.
Best regards,
Uladzislava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.