Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore redundant 'type-' labels #309

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pkgs/sdk_triage_bot/lib/triage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Future<void> 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Can also use list literal: [for (var l in labels) l.name]. I personally find it more readable.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know the different patterns! I'm still generally using list comprehensions.

if (existingLabels.isNotEmpty) {
logger.log('labels: ${existingLabels.join(', ')}');
logger.log('');
}
logger.log('"${issue.title}"');
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/sdk_triage_bot/test/triage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
}