Skip to content

Commit

Permalink
Fixed a bug in the PR labelling logic (#9679)
Browse files Browse the repository at this point in the history
Service labels start with service/ not services/
  • Loading branch information
melinath authored Dec 19, 2023
1 parent f86454b commit dc714ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tools/diff-processor/cmd/add_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (o *addLabelsOptions) run(args []string) error {
oldLabels := make(map[string]struct{}, len(issue.Labels))
for _, label := range issue.Labels {
oldLabels[label.Name] = struct{}{}
if strings.HasPrefix(label.Name, "services/") {
if strings.HasPrefix(label.Name, "service/") {
hasServiceLabels = true
}
}
Expand Down
12 changes: 6 additions & 6 deletions tools/diff-processor/cmd/add_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var enrolledTeamsYaml = []byte(`
services/google-x:
service/google-x:
resources:
- google_x_resource`)

Expand Down Expand Up @@ -112,7 +112,7 @@ func TestAddLabelsCmdRun(t *testing.T) {
Labels: []labeler.Label{},
PullRequest: map[string]any{},
},
expectedLabels: []string{"services/google-x"},
expectedLabels: []string{"service/google-x"},
},
"service labels are deduped": {
args: []string{"12345"},
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestAddLabelsCmdRun(t *testing.T) {
Labels: []labeler.Label{},
PullRequest: map[string]any{},
},
expectedLabels: []string{"services/google-x"},
expectedLabels: []string{"service/google-x"},
},
"existing labels are preserved": {
args: []string{"12345"},
Expand All @@ -173,7 +173,7 @@ func TestAddLabelsCmdRun(t *testing.T) {
Labels: []labeler.Label{{Name: "override-breaking-change"}},
PullRequest: map[string]any{},
},
expectedLabels: []string{"override-breaking-change", "services/google-x"},
expectedLabels: []string{"override-breaking-change", "service/google-x"},
},
"existing service label prevents new service labels": {
args: []string{"12345"},
Expand All @@ -195,7 +195,7 @@ func TestAddLabelsCmdRun(t *testing.T) {
githubIssue: &labeler.Issue{
Number: 12345,
Body: "Unused",
Labels: []labeler.Label{{Name: "services/google-z"}},
Labels: []labeler.Label{{Name: "service/google-z"}},
PullRequest: map[string]any{},
},
// nil indicates that the issue won't be updated at all (preserving existing labels)
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestAddLabelsCmdRun(t *testing.T) {
githubIssue: &labeler.Issue{
Number: 12345,
Body: "Unused",
Labels: []labeler.Label{{Name: "services/google-z"}},
Labels: []labeler.Label{{Name: "service/google-z"}},
PullRequest: map[string]any{},
},
expectError: true,
Expand Down

0 comments on commit dc714ec

Please sign in to comment.