Rishi Saraf
Rishi Saraf

Reputation: 1812

github api to know work breakdown for repository

For our organization, we want to plot metrics of new work (new changes in code), and rework (changing existing code) happening across the repository. Is there any GitHub API to get that info?

Upvotes: 1

Views: 41

Answers (1)

VonC
VonC

Reputation: 1329032

Is there any GitHub API to get that info?

No direct native API.

You would need the GitHub commits API for that, which you can query using the GitHub CLI gh (to be installed first):

gh api \
  -H "Accept: application/vnd.github+json" \
  /repos/OWNER/REPO/commits

For each commit, you can get a commit, which will include:

gh api \
  -H "Accept: application/vnd.github+json" \
  /repos/OWNER/REPO/commits/REF
  "stats": {
    "additions": 104,
    "deletions": 4,
    "total": 108
  },
  "files": [
    {
      "filename": "file1.txt",
      "additions": 10,
      "deletions": 2,
      "changes": 12,
      ...

That should be enough to determine if this is new work or rework.

Depending on the depth of the repository history, that might mean such a script could not scale if there is too many commit.
But it could work if you limit the analysis to a range of commits.

Upvotes: 1

Related Questions