sopel-irc / sopel-github

GitHub plugin for Sopel
Other
3 stars 13 forks source link

"Last Push" for a repo can be misleading #135

Open dgw opened 4 months ago

dgw commented 4 months ago

Anecdotally, the best way to see if a repo is still "active" is to look at how long it's been since the last commit to the repo's default branch. In most cases, how old that commit is is a decent proxy for how much development is happening.

GitHub's API doesn't return that value for the repo object's updated_at or pushed_at fields, though. pushed_at includes any ref/HEAD, including PR branches that might originate in a fork (because of GitHub internal implementation stuff). updated_at can be changed by any number of events, including issue/PR comments from random users, and who knows what else.

It is possible to take a repo's default_branch value and make a second API call to https://api.github.com/repos/{owner}/{repoName}/branches/{branchName}, then fetch commit.commit.author.date or commit.commit.committer.date* from there—but that is a lot of work for perhaps not much gain.

For that reason I'm not saying that this issue should be implemented. I'm just opening it so we remember this shortcoming of how things work now. At some point the plugin should be rewritten to use GitHub's GraphQL API, and that should let us fetch exactly the fields we want for any given handler without making multiple calls.**


* — This comes back as nested dictionaries in JSON, of course, but dot notation is easier to read than consecutive subscripts.

** — One downside: GitHub's GraphQL endpoint allows no unauthenticated access, unlike the REST API.