Repository navigation
fix: give existing score labels their band colour - #18
Merged
Merged
Conversation
Score labels were created with the band colour (green 2da44e, orange fb8c00, red d73a49), but a label that already existed was left as it was, so a score label made earlier in another colour (by hand, by another tool) kept that colour. An existing score label is now recoloured to its band, on GitLab (project labels; a group label can't be changed from the project) and GitHub. Best effort: a failure leaves the label and doesn't fail the review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Score labels in the green band didn't show green on the MR, while red and orange looked right.
The colours in the code have always been right: green
2da44e, orangefb8c00, redd73a49. ButSetScoreLabelsonly creates a label. When it already exists (GitLab 409, GitHub 422), it's kept as it is, so aQuality Score::85made earlier in another colour (by hand, by an earlier tool, or GitLab's default) never turns green.Fix
When the label already exists, read its colour and update it to the band colour if it differs:
GETandPUT /projects/:id/labels/:name. Only project labels are changed. A group label of the same name can't be changed from the project, so it's left as it is; change its colour or delete it in the group.GETandPATCH /repos/:o/:r/labels/:name.This is best effort: a failed recolour leaves the label and doesn't fail the review. A score label's name fixes its value and so its band, so recolouring is safe.
Tests
go test ./...passes. The label tests now cover a GitLab label made earlier in#6699cc, which is recoloured to#2da44e, and a GitHub label already green in a different case, which is left alone, next to one inededed, which is recoloured.🤖 Generated with Claude Code