From c54a81d60e80252abd3afa019a6dbde4399ebac6 Mon Sep 17 00:00:00 2001 From: fanshuai <1141904845@qq.com> Date: Fri, 20 Sep 2024 15:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E6=88=90=E5=BC=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/platform/utils/DVCUtils.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 e948666e..edebbfad 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 @@ -537,6 +537,8 @@ public class DVCUtils { fetchCommand.setCredentialsProvider(credentialsProvider).call(); } } + + //强制切换分支 public void gitCheckoutBranch(String localPath, String branchName) throws IOException, GitAPIException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder.setGitDir(new File(localPath, ".git")) @@ -546,7 +548,7 @@ public class DVCUtils { try (Git git = new Git(repository)) { CheckoutCommand checkoutCommand = git.checkout(); - checkoutCommand.setName(branchName).call(); + checkoutCommand.setName(branchName).setForce(true).call(); } } @@ -599,9 +601,9 @@ public class DVCUtils { runCommand(command, localPath); } - // 更新的 dvcPull 方法 + // 强制刷新 dvcPull 方法 public void dvcPull(String localPath) throws Exception { - String command = "dvc pull -v"; + String command = "dvc pull --force"; runCommand(command, localPath); }