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

Fix detection of previous PR annotation comments #3

Merged
merged 4 commits into from
Aug 8, 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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.21.2
version=1.21.3

Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ private void postSummaryComment(String graphqlUrl, Map<String, String> headers,

GetRepository.PullRequest pullRequest = getPullRequest(graphqlUrl, headers, pullRequestKey);
String pullRequestId = pullRequest.getId();
String projectCommentMarker = String.format("**Project ID:** %s%n", projectId);

getComments(pullRequest, graphqlUrl, headers, pullRequestKey).stream()
.filter(c -> "Bot".equalsIgnoreCase(c.getAuthor().getType()) && login.equalsIgnoreCase(c.getAuthor().getLogin()))
.filter(c -> !c.isMinimized())
.filter(c -> c.getBody().contains(String.format("**Project ID:** %s\r\n", projectId)))
.filter(c -> c.getBody().contains(projectCommentMarker))
.map(Comments.CommentNode::getId)
.forEach(commentId -> this.minimizeComment(graphqlUrl, headers, commentId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException {
ArgumentCaptor<GraphQLRequestEntity> getViewer = ArgumentCaptor.forClass(GraphQLRequestEntity.class);
when(graphQLTemplate.query(getViewer.capture(), eq(Viewer.class))).thenReturn(viewerResponseEntity);

String bodyString = objectMapper.writeValueAsString("**Project ID:** project-key-test" + System.lineSeparator());
GraphQLResponseEntity<GetRepository> getPullRequestResponseEntity =
objectMapper.readValue("{" +
"\"response\": " +
Expand All @@ -159,7 +160,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException {
" {" +
" \"id\": \"MDEyOklzc3VlQ29tbWVudDE1MDE3\"," +
" \"isMinimized\": false," +
" \"body\": \"**Project ID:** project-key-test\\r\\n\"," +
" \"body\": " + bodyString + "," +
" \"author\": {" +
" \"__typename\": \"Bot\"," +
" \"login\": \"test-sonar\"" +
Expand Down