From efd815edd79d4e373bce87d4c355451d027a8b6f Mon Sep 17 00:00:00 2001 From: fanshuai <1141904845@qq.com> Date: Tue, 10 Sep 2024 14:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B9=B6=E8=A1=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/platform/utils/DVCUtils.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java index 46fa7b52..559ee0ff 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java @@ -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(); - try (Repository repository = new FileRepositoryBuilder() .setGitDir(new File(localPath + "/.git")) .readEnvironment() @@ -344,10 +343,8 @@ public class DVCUtils { log.info("Repository is in a merging state, please resolve conflicts manually."); return; } - // 设置凭证提供者 UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); - // 获取远程分支 long fetchStartTime = System.currentTimeMillis(); FetchResult fetchResult = git.fetch() @@ -362,7 +359,6 @@ public class DVCUtils { for (Ref ref : fetchedRefs) { log.info("Fetched branch: " + ref.getName()); } - // 更新本地分支信息 long branchListStartTime = System.currentTimeMillis(); git.branchList() @@ -385,20 +381,15 @@ public class DVCUtils { } catch (InterruptedException e) { log.error("Executor service interrupted", e); } - long branchListEndTime = System.currentTimeMillis(); log.info("Branch list and update time: " + (branchListEndTime - branchListStartTime) + " ms"); - log.info("远程分支刷新到本地完成。"); - - // 切换分支 - gitCheckoutBranch(localPath, branch); - dvcCheckout(localPath); - } 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(); log.info("Total execution time: " + (endTime - startTime) + " ms"); }