Re:Show HN: First Commit – find the first commit of any GitH...
by brudgers on Sunday November 22, 2015 @11:10AM
(#10610447)
Yes, my intent was to provide the author a chance to talk about their work and share their enthusiasm. It's why I asked about code, since the answer "to how does it work?" is "type the repository url into the box".
Re:Show HN: First Commit – find the first commit of any GitH...
by wonderfuly on Sunday November 22, 2015 @10:10AM
(#10610248)
thanks for you explanation!
Anyways, I did a quick look at the source file[1] and it looks like it depends on the assumption of github returning 35 commit titles per page. From that, it divides total # of commits by 35 to derive the url for the last page containing the 1st commit. (The url you'd arrive at if you if you repeatedly clicked the "Older" button on github to get to the final page which contains the 1st commit.) It then scrapes that url for relevant data. (It uses the cheerio library to help with scraping.)
I'm not familiar enough with github's HTML navigation and page formatting to know if this method is fragile or robust. Github does offer an API[2] so it may be possible to get the 1st commit that way instead of scraping HTML that was intended for display in a web browser.
Excerpt of the arithmetic:
[1]https://github.com/wong2/first-commit/blob/master/app/github...[2]https://developer.github.com/v3/git/commits/