Normalize forge statuses#121
Conversation
andrew
left a comment
There was a problem hiding this comment.
Nice implementation of #17. The Normalize* helpers are well tested, the ~string generic on assertEqual keeps the adapter tests tidy, and the reverse mappers (githubPermission, giteaPermission, the GitLab fallback in parseGitLabAccessLevel) mean --permission write now works against every forge, which is a real usability win.
A few mapping gaps to close before merging, mainly the Bitbucket issue-state regression. See inline.
Minor naming thought: IssueState but PRStatus, with the struct field still called State and the JSON key "state". PRState would be more consistent, but not worth churning if you'd rather keep it.
| result := forge.CIRun{ | ||
| ID: int64(p.ID), | ||
| Status: p.Status, | ||
| Status: forge.NormalizeCIStatus(p.Status), |
There was a problem hiding this comment.
Not blocking, just noting: GitLab merges status and conclusion into one field, so a successful pipeline ends up Status: success, Conclusion: "" while GitHub is Status: completed, Conclusion: success. Callers still have to check both. Worth a follow-up to populate Conclusion from terminal GitLab statuses now that the values are normalized.
There was a problem hiding this comment.
Added logic to explicitly populate Conclusion for GitLab pipelines and jobs if they've reached a terminal state.
andrew
left a comment
There was a problem hiding this comment.
Thanks, all addressed. One small ask: add the new cases (on_hold, invalid, duplicate, wontfix, triage, maintain, planner) to the table in statuses_test.go so the Bitbucket regression stays covered. Happy to merge once that's in.
andrew
left a comment
There was a problem hiding this comment.
Actually, let's hold merge until the new mappings are covered: add on_hold, invalid, duplicate, wontfix, triage, maintain, planner to the tables in statuses_test.go. Everything else from the first round is addressed.
|
Thanks @andrew |
closes #17
Summary
Adds shared normalized status enum types across forge implementations.
This includes normalized types for:
Also updates GitHub, GitLab, Gitea, and Bitbucket adapters to map forge-specific values into the shared enums, so callers do not need to handle each forge’s raw status names.
Testing
env GOCACHE=/private/tmp/forge-gocache go test ./... git diff --check