Merge pull request #6803 from ViacheslavKlimov/vc-fixes

[WIP] [3.4] Version control fixes
This commit is contained in:
Andrew Shvayka 2022-06-23 15:44:36 +03:00 committed by GitHub
commit 71ed6abee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 23 deletions

View File

@ -484,29 +484,25 @@ public class EntitiesVersionControlController extends BaseController {
MARKDOWN_CODE_BLOCK_END) MARKDOWN_CODE_BLOCK_END)
@GetMapping("/branches") @GetMapping("/branches")
public DeferredResult<List<BranchInfo>> listBranches() throws Exception { public DeferredResult<List<BranchInfo>> listBranches() throws Exception {
try { accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ);
accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ); final TenantId tenantId = getTenantId();
final TenantId tenantId = getTenantId(); ListenableFuture<List<BranchInfo>> branches = versionControlService.listBranches(tenantId);
ListenableFuture<List<BranchInfo>> branches = versionControlService.listBranches(tenantId); return wrapFuture(Futures.transform(branches, remoteBranches -> {
return wrapFuture(Futures.transform(branches, remoteBranches -> { List<BranchInfo> infos = new ArrayList<>();
List<BranchInfo> infos = new ArrayList<>(); BranchInfo defaultBranch;
BranchInfo defaultBranch; String defaultBranchName = versionControlService.getVersionControlSettings(tenantId).getDefaultBranch();
String defaultBranchName = versionControlService.getVersionControlSettings(tenantId).getDefaultBranch(); if (StringUtils.isNotEmpty(defaultBranchName)) {
if (StringUtils.isNotEmpty(defaultBranchName)) { defaultBranch = new BranchInfo(defaultBranchName, true);
defaultBranch = new BranchInfo(defaultBranchName, true); } else {
} else { defaultBranch = remoteBranches.stream().filter(BranchInfo::isDefault).findFirst().orElse(null);
defaultBranch = remoteBranches.stream().filter(BranchInfo::isDefault).findFirst().orElse(null); }
} if (defaultBranch != null) {
if (defaultBranch != null) { infos.add(defaultBranch);
infos.add(defaultBranch); }
} infos.addAll(remoteBranches.stream().filter(b -> !b.equals(defaultBranch))
infos.addAll(remoteBranches.stream().filter(b -> !b.equals(defaultBranch)) .map(b -> new BranchInfo(b.getName(), false)).collect(Collectors.toList()));
.map(b -> new BranchInfo(b.getName(), false)).collect(Collectors.toList())); return infos;
return infos; }, MoreExecutors.directExecutor()));
}, MoreExecutors.directExecutor()));
} catch (Exception e) {
throw handleException(e);
}
} }
} }

View File

@ -357,6 +357,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont
return EntityImportSettings.builder() return EntityImportSettings.builder()
.updateRelations(config.isLoadRelations()) .updateRelations(config.isLoadRelations())
.saveAttributes(config.isLoadAttributes()) .saveAttributes(config.isLoadAttributes())
.saveCredentials(config.isLoadCredentials())
.findExistingByName(config.isFindExistingEntityByName()) .findExistingByName(config.isFindExistingEntityByName())
.build(); .build();
} }