Repository navigation
Add subject number and repository URL to notifications - #185
Conversation
andrew
left a comment
There was a problem hiding this comment.
Thanks, the GitHub and Gitea conversions look right. One thing before merge:
gitlab/notifications.go: RepoURL is taken from any TargetURL containing /-/, including targets that are not in a project. An epic todo with https://gitlab.com/groups/group/-/epics/3 gets RepoURL = https://gitlab.com/groups/group, a group page, while Repo stays empty because the todo has no Project. That contradicts the doc comment on Notification, which says RepoURL is the web page of the repository. Please only set RepoURL inside the if t.Project != nil block, and change the "epic keeps no number" test case to expect an empty RepoURL.
|
Thanks, fixed. |
andrew
left a comment
There was a problem hiding this comment.
Thanks, that's the fix. Merging.
Closes #48
Notifications now carry the subject's number and web page, so consumers can link a notification to its issue or pull request without another API call.
URLalso means the same thing on every forge.Changes to
NotificationSubjectNumberRepoURLURLBefore this change GitHub set
URLto the repository page while GitLab and Gitea set it to the subject page.RepoURLkeeps the repository link available now that GitHub'sURLpoints at the subject.How each forge fills them
SubjectNumberURLRepoURLSubject.URLRepository.HTMLURLTarget.IIDfor issues and merge requestsTargetURL(unchanged)TargetURLup to/-/Subject.HTMLURL, falling back toSubject.URLSubject.HTMLURL(unchanged)Repository.HTMLURL.../repos/octocat/hello/pulls/42.gitHubSubjectLinkmaps issues, pulls, discussions and commits to<repo>/issues/N,/pull/N,/discussions/Nand/commit/<sha>. It builds on the repository's web URL, so GitHub Enterprise works without knowing the web host. Releases are addressed by ID rather than tag in the API, so theirURLis left empty instead of guessed.<project>/-/, soRepoURLis the part ofTargetURLbefore that separator./issues/Nor/pulls/N.Behaviour change
On GitHub,
Notification.URLused to be the repository page and is now the subject page. Nothing in this repo reads it (the CLI doesn't printURL), but external callers relying on the old value should switch toRepoURL.Tests
SubjectNumber,URLandRepoURL.TestGitHubSubjectLinkcovers issues, pull requests, discussions, commits, releases, GitHub Enterprise paths, a trailing slash on the repository URL, missing URLs, non-numeric IDs and non-repository paths.TestConvertGitLabTodoSubjectcovers merge requests in a subgroup, commits, epics and todos without a target.TestConvertGiteaNotificationSubjectcovers pulls, the API URL fallback, commits, repositories, non-numeric paths and missing URLs.go test -race ./...,go test -tags=tinygo ./gitlab, the js/wasip1 WebAssembly builds, the tinygo CI commands andgolangci-lintv2.14.0 all pass locally.