(String remotePath)
| 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(); |
no test coverage detected