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.
| case "open", "opened", "new", "reopened": | ||
| return IssueStateOpen | ||
| case "closed", "resolved", "declined", "rejected", "done": | ||
| return IssueStateClosed | ||
| default: | ||
| return IssueStateUnknown | ||
| } |
There was a problem hiding this comment.
Add Bitbucket's invalid, duplicate, wontfix (and probably on_hold → open) here so bitbucket/issues.go doesn't regress to unknown for those states.
| 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.
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