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:
function getFirstPageUrl(repo, num_of_commits) {
const COMMITS_PER_PAGE = 35;
var first_page = Math.ceil(num_of_commits / COMMITS_PER_PAGE);
return `${BASE_URL}/${repo}/commits?page=${first_page}`;
}
[1]https://github.com/wong2/first-commit/blob/master/app/github...