Skip to content

Commit

Permalink
fix: fix missing comment on pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rudyk committed Sep 12, 2023
1 parent b560674 commit 57ff5ec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/lpvs/service/LPVSGitHubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,26 @@ public void commentResults(LPVSQueue webhookConfig, List<LPVSFile> scanResults,
lpvsDetectedLicenseRepository.saveAndFlush(detectedIssue);
}
commitCommentBuilder.append("</ul>");
if (null != webhookConfig.getHubLink()) {
commitCommentBuilder.append("(");
commitCommentBuilder.append(webhookConfig.getHubLink());
commitCommentBuilder.append(")");
}
commitComment += commitCommentBuilder.toString();
}

if (hasProhibitedOrRestricted || hasConflicts) {
lpvsPullRequest.setStatus(LPVSPullRequestStatus.ISSUES_DETECTED.toString());
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment("**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" +
commitComment + "(" + webhookConfig.getHubLink() + ")</p>");
commitComment + "</p>");
repository.createCommitStatus(webhookConfig.getHeadCommitSHA(), GHCommitState.FAILURE, null,
"Potential license problem(s) detected", "[License Pre-Validation Service]");
} else {
lpvsPullRequest.setStatus(LPVSPullRequestStatus.COMPLETED.toString());
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment("**\\[License Pre-Validation Service\\]** No license issue detected \n\n" +
commitComment + "(" + webhookConfig.getHubLink() + ")</p>");
commitComment + "</p>");
repository.createCommitStatus(webhookConfig.getHeadCommitSHA(), GHCommitState.SUCCESS, null,
"No license issue detected", "[License Pre-Validation Service]");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/service/LPVSQueueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public void processWebHook(LPVSQueue webhookConfig) throws IOException {
}
delete(webhookConfig);
} catch (Exception | Error e) {
pullRequest.setStatus(LPVSPullRequestStatus.INTERNAL_ERROR.toString());
pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest);
log.error("Can't authorize commentResults() " + e);
e.printStackTrace();
pullRequest.setStatus(LPVSPullRequestStatus.INTERNAL_ERROR.toString());
delete(webhookConfig);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public List<LPVSFile> checkLicenses(LPVSQueue webhookConfig) {
.replaceAll("],", "\"],")
.replaceAll("\"\\{\"","{\"")
.replaceAll("\"}\"]", "\"}]")
.replaceAll("\\[\"\"\\]", "[]")
.replaceAll("incompatible_with\" : (\".*?\"), \"name", "incompatible_with\" : \\[$1\\], \"name")
;
content = content.substring(1, content.length() - 1);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent {
" * Use of this source code is governed by a MIT license that can be\n" +
" * found in the LICENSE file.\n" +
" */\n\n\n\n\n" +
"(null)</p>";
"</p>";

@BeforeEach
void setUp() {
Expand Down

0 comments on commit 57ff5ec

Please sign in to comment.