|
|
|
@@ -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"); |
|
|
|
} |
|
|
|
|