Browse Source

优化并行处理

dev-restore_mount
fanshuai 1 year ago
parent
commit
efd815edd7
1 changed files with 5 additions and 14 deletions
  1. +5
    -14
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java

+ 5
- 14
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java View File

@@ -327,9 +327,8 @@ public class DVCUtils {
} }




public static void refreshRemoteBranches(String localPath, String username, String password, String branch) throws IOException, GitAPIException {
public static void refreshRemoteBranches(String localPath, String username, String password, String branch) throws Exception {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();

try (Repository repository = new FileRepositoryBuilder() try (Repository repository = new FileRepositoryBuilder()
.setGitDir(new File(localPath + "/.git")) .setGitDir(new File(localPath + "/.git"))
.readEnvironment() .readEnvironment()
@@ -344,10 +343,8 @@ public class DVCUtils {
log.info("Repository is in a merging state, please resolve conflicts manually."); log.info("Repository is in a merging state, please resolve conflicts manually.");
return; return;
} }

// 设置凭证提供者 // 设置凭证提供者
UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password);

// 获取远程分支 // 获取远程分支
long fetchStartTime = System.currentTimeMillis(); long fetchStartTime = System.currentTimeMillis();
FetchResult fetchResult = git.fetch() FetchResult fetchResult = git.fetch()
@@ -362,7 +359,6 @@ public class DVCUtils {
for (Ref ref : fetchedRefs) { for (Ref ref : fetchedRefs) {
log.info("Fetched branch: " + ref.getName()); log.info("Fetched branch: " + ref.getName());
} }

// 更新本地分支信息 // 更新本地分支信息
long branchListStartTime = System.currentTimeMillis(); long branchListStartTime = System.currentTimeMillis();
git.branchList() git.branchList()
@@ -385,20 +381,15 @@ public class DVCUtils {
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error("Executor service interrupted", e); log.error("Executor service interrupted", e);
} }

long branchListEndTime = System.currentTimeMillis(); long branchListEndTime = System.currentTimeMillis();
log.info("Branch list and update time: " + (branchListEndTime - branchListStartTime) + " ms"); log.info("Branch list and update time: " + (branchListEndTime - branchListStartTime) + " ms");

log.info("远程分支刷新到本地完成。"); log.info("远程分支刷新到本地完成。");

// 切换分支
gitCheckoutBranch(localPath, branch);
dvcCheckout(localPath);

} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e);
log.error("Error occurred while refreshing remote branches ", e); ;
} }

// 切换分支
gitCheckoutBranch(localPath, branch);
dvcCheckout(localPath);
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
log.info("Total execution time: " + (endTime - startTime) + " ms"); log.info("Total execution time: " + (endTime - startTime) + " ms");
} }


Loading…
Cancel
Save