Skip to content

Commit

Permalink
Fix missing comment on pull request (#211)
Browse files Browse the repository at this point in the history
fix: fix missing comment on pull request
  • Loading branch information
m-rudyk authored Sep 14, 2023
1 parent 57a8722 commit d7d8009
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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 @@ -251,21 +251,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
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 d7d8009

Please sign in to comment.