Mahdi
Mahdi

Reputation: 2283

Count number of lines in a GitHub repository without cloning

There are similar questions but all of them need you to clone repository and then run some utility on it. I need a web-service which can give me those stats (something like using an URL e.g. http://my-sloc-counter.com/project1 to get SLOC stats for project1 from GitHub)

Upvotes: 6

Views: 19281

Answers (3)

BR123
BR123

Reputation: 322

You can use https://sloc.xyz/github/user/repo (replace "user" and "repo" with what you need, example: https://sloc.xyz/github/boyter/scc). This is the service sitting behind the "Total lines" badge from the README.md of https://github.com/boyter/scc.

Upvotes: 0

VonC
VonC

Reputation: 1324515

For GitHub specifically, you have a possibility to compute an approximation of that data (LOC: Lines of Code) through the GitHub Statistics API.

You can see an example in "Can you get the number of lines of code from a GitHub repository?", which does not involve cloning the repo.


More recently, you have the project jolav/codetabs (initally mentioned by Sclerosis), based on Curtis Gagliardi cgag/loc for counting lines of code.
It includes a service for counting lines for any public GitHub repository:
codetabs.com/count-loc/count-loc-online.html.

Example for my project: https://api.codetabs.com/v1/loc?github=vonc/seec


Problem (for both solutions): they do count the lines of all files inside a repo, so if you have vendored files like in a Go project, you will have a hard time distinguishing what you wrote from what you have vendored.

Upvotes: 7

Kas Elvirov
Kas Elvirov

Reputation: 7980

There is browser extension for Google Chrome named Gloc.

Upvotes: 2

Related Questions