Merge pull request #6803 from ViacheslavKlimov/vc-fixes
[WIP] [3.4] Version control fixes
This commit is contained in:
		
						commit
						71ed6abee8
					
				@ -484,29 +484,25 @@ public class EntitiesVersionControlController extends BaseController {
 | 
			
		||||
            MARKDOWN_CODE_BLOCK_END)
 | 
			
		||||
    @GetMapping("/branches")
 | 
			
		||||
    public DeferredResult<List<BranchInfo>> listBranches() throws Exception {
 | 
			
		||||
        try {
 | 
			
		||||
            accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ);
 | 
			
		||||
            final TenantId tenantId = getTenantId();
 | 
			
		||||
            ListenableFuture<List<BranchInfo>> branches = versionControlService.listBranches(tenantId);
 | 
			
		||||
            return wrapFuture(Futures.transform(branches, remoteBranches -> {
 | 
			
		||||
                List<BranchInfo> infos = new ArrayList<>();
 | 
			
		||||
                BranchInfo defaultBranch;
 | 
			
		||||
                String defaultBranchName = versionControlService.getVersionControlSettings(tenantId).getDefaultBranch();
 | 
			
		||||
                if (StringUtils.isNotEmpty(defaultBranchName)) {
 | 
			
		||||
                    defaultBranch = new BranchInfo(defaultBranchName, true);
 | 
			
		||||
                } else {
 | 
			
		||||
                    defaultBranch = remoteBranches.stream().filter(BranchInfo::isDefault).findFirst().orElse(null);
 | 
			
		||||
                }
 | 
			
		||||
                if (defaultBranch != null) {
 | 
			
		||||
                    infos.add(defaultBranch);
 | 
			
		||||
                }
 | 
			
		||||
                infos.addAll(remoteBranches.stream().filter(b -> !b.equals(defaultBranch))
 | 
			
		||||
                        .map(b -> new BranchInfo(b.getName(), false)).collect(Collectors.toList()));
 | 
			
		||||
                return infos;
 | 
			
		||||
            }, MoreExecutors.directExecutor()));
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw handleException(e);
 | 
			
		||||
        }
 | 
			
		||||
        accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ);
 | 
			
		||||
        final TenantId tenantId = getTenantId();
 | 
			
		||||
        ListenableFuture<List<BranchInfo>> branches = versionControlService.listBranches(tenantId);
 | 
			
		||||
        return wrapFuture(Futures.transform(branches, remoteBranches -> {
 | 
			
		||||
            List<BranchInfo> infos = new ArrayList<>();
 | 
			
		||||
            BranchInfo defaultBranch;
 | 
			
		||||
            String defaultBranchName = versionControlService.getVersionControlSettings(tenantId).getDefaultBranch();
 | 
			
		||||
            if (StringUtils.isNotEmpty(defaultBranchName)) {
 | 
			
		||||
                defaultBranch = new BranchInfo(defaultBranchName, true);
 | 
			
		||||
            } else {
 | 
			
		||||
                defaultBranch = remoteBranches.stream().filter(BranchInfo::isDefault).findFirst().orElse(null);
 | 
			
		||||
            }
 | 
			
		||||
            if (defaultBranch != null) {
 | 
			
		||||
                infos.add(defaultBranch);
 | 
			
		||||
            }
 | 
			
		||||
            infos.addAll(remoteBranches.stream().filter(b -> !b.equals(defaultBranch))
 | 
			
		||||
                    .map(b -> new BranchInfo(b.getName(), false)).collect(Collectors.toList()));
 | 
			
		||||
            return infos;
 | 
			
		||||
        }, MoreExecutors.directExecutor()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -357,6 +357,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont
 | 
			
		||||
        return EntityImportSettings.builder()
 | 
			
		||||
                .updateRelations(config.isLoadRelations())
 | 
			
		||||
                .saveAttributes(config.isLoadAttributes())
 | 
			
		||||
                .saveCredentials(config.isLoadCredentials())
 | 
			
		||||
                .findExistingByName(config.isFindExistingEntityByName())
 | 
			
		||||
                .build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user