MCPcopy Create free account
hub / github.com/ReZeroS/git / fetch

Method fetch

src/main/java/club/qqtim/command/Fetch.java:47–74  ·  view source on GitHub ↗
(String remotePath)

Source from the content-addressed store, hash-verified

45 }
46
47 public static void fetch(String remotePath) {
48
49 {
50
51 log.debug("Will fetch the following refs:");
52
53 final String currentDir = FileUtil.getCurrentDir();
54 FileUtil.setRootPathContext(remotePath);
55
56 final List<RefObjValue> remoteRefs = getRemoteRefs(remotePath, REMOTE_REFS_BASE);
57
58 final List<String> objectIds = ZitContext.iteratorObjectsInCommits(
59 remoteRefs.stream().map(RefObjValue::getValue).distinct().collect(Collectors.toList()));
60
61 FileUtil.setRootPathContext(currentDir);
62
63 objectIds.forEach(objectId -> ZitContext.fetchObjectIfMissing(objectId, remotePath));
64
65 remoteRefs.forEach(remoteRef -> {
66 final String remoteName = remoteRef.getRefName();
67 final Path refName = Paths.get(REMOTE_REFS_BASE).relativize(Paths.get(remoteName));
68
69 ZitContext.updateRef(Paths.get(LOCAL_REFS_BASE).resolve(refName).toString(),
70 new RefValue(false, remoteRef.getValue()));
71 });
72 }
73
74 }
75
76 public static List<RefObjValue> getRemoteRefs(String remotePath) {
77 final String currentDir = FileUtil.getCurrentDir();

Callers 1

runMethod · 0.95

Calls 7

getCurrentDirMethod · 0.95
setRootPathContextMethod · 0.95
getRemoteRefsMethod · 0.95
fetchObjectIfMissingMethod · 0.95
updateRefMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected