Fasthub: Feature: Enumerate number of commits in repository and branches

Created on 29 Mar 2017  路  14Comments  路  Source: k0shk0sh/FastHub

Is possible to enumerate number of commits to each repository in a certain branch? Ej. Linux Kernel Repository: In master branch: 420,000 commits

Completed Enhancement

Most helpful comment

We finally found the real answer and this is single request only.

Just make a HTTP GET request to this link https://api.github.com/repos/k0shk0sh/FastHub/commits?per_page=1 or your repository and you need to see HTTP response headers. See Link field, second link's page= property gives you the last page which is total number of commits.

All 14 comments

Well, I'm not really sure tbh, I haven't seen it passed along with data returned by the API, if it isn't possible I'll update later.

@kutsan thanks buddy :)

@kutsan this is weekly commits count and not over all, however even if we use https://api.github.com/repos/k0shk0sh/fasthub/stats/contributors still the count is incorrect comparing to the GitHub commit count in Github repo. this will be in preview until we figure out a way of doing it.

I thought you can sum all of them but you are right. Seems like they contain only 52 weeks.

@kutsan even this https://api.github.com/repos/k0shk0sh/fasthub/stats/commit_activity doesn't help, and I found something weird, if you to write FastHub there will be nothing to show, only when you use small case then it'll work :D

Why they just not serve all informations about that repo under URL like repos/k0shk0sh/fasthub/stats/. So, the only way get that count, fetch the HTML URL as XML and parse, get commits count?

@kutsan because it's GitHub 馃榿

Okay, I found the "only" way to get total number of commits but little expensive, not sure is it worth though.

Here it is:
https://api.github.com/repos/k0shk0sh/FastHub/commits?per_page=100&page=1
https://api.github.com/repos/k0shk0sh/FastHub/commits?per_page=100&page=2
https://api.github.com/repos/k0shk0sh/FastHub/commits?per_page=100&page=3
... then, sum of length of array.

Yeah, a lot of HTTP request. Can't imagine what will happen for 1K+ commits. And probably, we need cloud functions for that. Otherwise not gonna happen.

And as I said the other way, fetching https://github.com/k0shk0sh/FastHub link as HTML and then Regex search \d+\scommits something like that, more hack-ish but not so expensive.

I guess, the latter is better, not to expensive. but then, I haven't decide yet to do sniffing :D

@kutsan alright we might be able to do it via search commits api, but its in preview so we just do it and if it breaks its okay I guess. Not a big deal.

-- this is invalid & doesn't work lol

We finally found the real answer and this is single request only.

Just make a HTTP GET request to this link https://api.github.com/repos/k0shk0sh/FastHub/commits?per_page=1 or your repository and you need to see HTTP response headers. See Link field, second link's page= property gives you the last page which is total number of commits.

this issued fixed by this commit 8e8baca

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Janrupf picture Janrupf  路  3Comments

dikiaap picture dikiaap  路  4Comments

szechyjs picture szechyjs  路  3Comments

yochananmarqos picture yochananmarqos  路  3Comments

tom-ando picture tom-ando  路  3Comments