diff --git a/pkgs/sdk_triage_bot/lib/triage.dart b/pkgs/sdk_triage_bot/lib/triage.dart index de5d0498..a4a0cefe 100644 --- a/pkgs/sdk_triage_bot/lib/triage.dart +++ b/pkgs/sdk_triage_bot/lib/triage.dart @@ -29,9 +29,9 @@ Future triage( final issue = await githubService.fetchIssue(sdkSlug, issueNumber); logger.log('## issue ${issue.htmlUrl}'); logger.log(''); - final labels = issue.labels.map((l) => l.name).toList(); - if (labels.isNotEmpty) { - logger.log('labels: ${labels.join(', ')}'); + final existingLabels = issue.labels.map((l) => l.name).toList(); + if (existingLabels.isNotEmpty) { + logger.log('labels: ${existingLabels.join(', ')}'); logger.log(''); } logger.log('"${issue.title}"'); @@ -88,6 +88,11 @@ ${trimmedBody(comment.body ?? '')} exit(1); } + // If an issue already has a `type-` label, we don't need to apply more. + if (existingLabels.any((label) => label.startsWith('type-'))) { + newLabels.removeWhere((label) => label.startsWith('type-')); + } + // ask for the summary String summary; try { diff --git a/pkgs/sdk_triage_bot/test/triage_test.dart b/pkgs/sdk_triage_bot/test/triage_test.dart index c07f737f..588abcd2 100644 --- a/pkgs/sdk_triage_bot/test/triage_test.dart +++ b/pkgs/sdk_triage_bot/test/triage_test.dart @@ -74,4 +74,26 @@ void main() { expect(githubService.updatedLabels, contains(startsWith('area-'))); expect(githubService.updatedLabels, contains('triage-automation')); }); + + test('ignore redundant type labels', () async { + final githubService = GithubServiceMock(); + final geminiService = GeminiServiceStub(); + + githubService.returnedIssue = Issue( + url: 'https://github.com/dart-lang/sdk/issues/55869', + title: 'Add full support for service ID zones', + number: mockIssueNumber, + body: 'Lorem ipsum.', + labels: [IssueLabel(name: 'type-enhancement')], + ); + + await triage( + mockIssueNumber, + githubService: githubService, + geminiService: geminiService, + logger: TestLogger(), + ); + + expect(githubService.updatedLabels, ['area-vm', 'triage-automation']); + }); }