Skip to content

Commit bd476d3

Browse files
author
jicheng
committed
v1.3.7: 性能优化 - 移除 fetch 操作,纯本地缓存读取
- 移除工作空间模式下的 fetch 操作 - 改为纯读取本地缓存 refs(瞬间响应) - 无缓存时回退到 ls-remote 等其他方法 - 更新日志说明使用缓存策略
1 parent c5437fb commit bd476d3

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>io.jenkins.plugins</groupId>
1313
<artifactId>active-git-branches-plugin</artifactId>
14-
<version>1.3.5</version>
14+
<version>1.3.7</version>
1515
<packaging>hpi</packaging>
1616

1717
<name>Active Git Branches Parameter</name>

src/main/java/io/jenkins/plugins/activegitbranches/ActiveGitBranchesParameterDefinition.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,23 +315,17 @@ private List<BranchInfo> fetchBranchesFromWorkspace(FilePath workspace) throws I
315315
git.addCredentials(repositoryUrl, credentials);
316316
}
317317

318-
// Fetch latest refs from remote (lightweight, only updates refs)
319-
try {
320-
git.fetch_().from(new URIish(repositoryUrl), Collections.emptyList()).execute();
321-
LOGGER.info("Fetched latest refs from remote");
322-
} catch (Exception e) {
323-
LOGGER.log(Level.WARNING, "Failed to fetch from remote, using cached refs", e);
324-
}
325-
326-
// Read local refs (now up-to-date)
318+
// Read cached local refs (instant, no network)
327319
List<BranchInfo> localRefs = readLocalRefs(git);
320+
321+
// If we have cached refs, use them directly (fast path)
328322
if (!localRefs.isEmpty()) {
329-
LOGGER.info("Using local refs (" + localRefs.size() + " branches)");
323+
LOGGER.info("Using cached local refs (" + localRefs.size() + " branches)");
330324
return applyLimits(localRefs);
331325
}
332326

333-
// No local refs found, return null to fall back to other methods
334-
LOGGER.info("No local refs found in workspace, will use fallback method");
327+
// No cached refs in workspace, return null to fall back to ls-remote
328+
LOGGER.info("No cached refs in workspace, falling back to other method");
335329
return null;
336330
}
337331

0 commit comments

Comments
 (0)