Skip to content

On branch limit analysis to new issues since last leak period #16

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

Merged
merged 4 commits into from
Aug 18, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public String getGitLabUrl(@Nullable String revision, String path, @Nullable Int
@Override
public void createOrUpdateReviewComment(String revision, String fullPath, Integer line, String body) {
try {
if (config.isMergeRequestDiscussionEnabled()) {
if (config.isMergeRequestDiscussionEnabled() && config.mergeRequestIid() != -1) {
createReviewDiscussion(fullPath, line, body);
} else {
gitLabAPIV4.getGitLabAPICommits().postCommitComments(gitLabProject.getId(), revision != null ? revision : getFirstCommitSHA(), body, fullPath, line, "new");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ private Issues.SearchWsResponse searchIssues(String componentKey, int pullReques
}
else if (isNotBlankAndNotEmpty(branch)) {
searchRequest.setBranch(branch);
if (! gitLabPluginConfiguration.allIssues()) {
searchRequest.setSinceLeakPeriod("true");
}
}
return wsClient.issues().search(searchRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,35 @@ public void testReviewComment() throws IOException {
}

@Test
public void testCreateReviewDiscussionMissingIidFail() {
public void testCreateReviewDiscussionMissingIidFallbackCommentOnCommit() throws IOException {
GitLabPluginConfiguration gitLabPluginConfiguration = mock(GitLabPluginConfiguration.class);
when(gitLabPluginConfiguration.commitSHA()).thenReturn(Collections.singletonList("1"));
when(gitLabPluginConfiguration.refName()).thenReturn("master");
when(gitLabPluginConfiguration.mergeRequestIid()).thenReturn(-1);
when(gitLabPluginConfiguration.isMergeRequestDiscussionEnabled()).thenReturn(true);

GitLabApiV4Wrapper facade = new GitLabApiV4Wrapper(gitLabPluginConfiguration);

GitLabAPI gitLabAPI = mock(GitLabAPI.class);
facade.setGitLabAPI(gitLabAPI);

GitLabAPICommits gitLabAPICommits = mock(GitLabAPICommits.class);
when(gitLabAPICommits.postCommitComments("1", "1", "pending", "master", null, null)).thenReturn(null);

when(gitLabAPI.getGitLabAPICommits()).thenReturn(gitLabAPICommits);

GitLabProject gitLabProject = mock(GitLabProject.class);
when(gitLabProject.getId()).thenReturn(1);
facade.setGitLabProject(gitLabProject);

assertThatIllegalArgumentException().isThrownBy(() ->
facade.createOrUpdateReviewComment(null, "src/main/Foo.java", 5, "nothing"));
facade.createOrUpdateReviewComment(null, "src/main/Foo.java", 5, "nothing");

verify(gitLabAPICommits).postCommitComments(1, "1", "nothing", "src/main/Foo.java", 5, "new");



//assertThatIllegalArgumentException().isThrownBy(() ->
// facade.createOrUpdateReviewComment(null, "src/main/Foo.java", 5, "nothing"));
}

@Test
Expand Down