Get commits of GitHub repo since the last version tag with GitHub API.
Equivalent to this in a local git repo:
git log <yourlasttag>..HEAD
When there are many small (possibly inter-dependent) repos, we may forgot to tag and publish the repos after commits and PR.
This library list the commits since the last tagging. We can then evaluate the commits and determine whether we should create a new release for the repo.
I assume:
- each tagging is followed by an
npm publish
(seenpmpub
) - tagging follows SemVer, versions with meta are considered unofficial and ignored
- forks are not to be tracked
npm i github-commits-since-tag
GitHub imposes a per IP rate limit on GitHub API requests, you need a Personal access tokens to enjoy higher rates. A token with no specific role should suffice.
// instance creation
const GHcst = require('github-commits-since-tag');
const ghcst = new GHcst({
user: 'GitHub username',
token: 'GitHub token'
});
// list specific repo (accessibility depends on token)
// rejected upon invalid repo, forked repo, repo without tag
ghcst.commitsForRepo('github/hub')
.then(result => console.log(result))
.catch(err => console.log(err));
// list all repo (accessibility depends on token)
// ignore forked repo, repo without tag
ghcst.commitsForOwner('github')
.then(results => console.log(results))
.catch(err => console.log(err));
Supported DEBUG tags: ghcst:flow, ghcst:data.
See visionmedia/debug for details.
GitHub API v3 | GitHub Developer Guide
mikeal/contribution-reports: Tools for running contribution reports on GitHub repos and orgs.