Skip to content

Commit

Permalink
Test 16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
C4tWithShell committed Dec 11, 2023
1 parent 6f32265 commit 8f58152
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ private static Branch load(ScannerReport.Metadata metadata, Project project, DbC
throw new IllegalStateException("Could not find main branch");
}
} else {
String targetBranch = "main";
try {
targetBranch = StringUtils.trimToNull(metadata.getReferenceBranchName());
} catch (IllegalStateException ex) {
throw new IllegalStateException(String.format("Target branch exceptions:"), ex);
}


String targetBranch = StringUtils.trimToNull(metadata.getReferenceBranchName());
ScannerReport.Metadata.BranchType branchType = metadata.getBranchType();
if (null == targetBranchName) {
targetBranchName = targetBranch;
Expand Down Expand Up @@ -109,7 +102,7 @@ private static Branch createPullRequest(ScannerReport.Metadata metadata, DbClien
private static Branch createBranch(DbClient dbClient, String branchName, String projectUuid, String targetBranch) {
String targetUuid;
if (null == targetBranch) {
targetUuid = projectUuid;
targetUuid = selectMainBranchByProjectUuid(dbClient, projectUuid);
} else {
Optional<BranchDto> branchDto = findBranchByKey(projectUuid, targetBranch, dbClient);
if (branchDto.isPresent()) {
Expand All @@ -136,4 +129,9 @@ private static Optional<BranchDto> findBranchByKey(String projectUuid, String ke
}
}

public Optional<BranchDto> selectMainBranchByProjectUuid(DbClient dbClient, String projectUuid) {
try (DbSession dbSession = dbClient.openSession(false)) {
return dbClient.branchDao().selectMainBranchByProjectUuid(dbSession, projectUuid);
}
}
}

0 comments on commit 8f58152

Please sign in to comment.