public void checkoutThroughCache(VcsSupport vcsSupport, final String repositoryUrl, File targetDirectory, String branch, boolean recursive) throws IOException { String normalizedUrl = vcsSupport.normalizeRepositoryUrl(repositoryUrl); String moduleInCacheName = cacheMapping.getProperty(normalizedUrl); boolean newName = moduleInCacheName == null; if (newName) { moduleInCacheName = sanitize(normalizedUrl); } File moduleInCache = new File(cacheDirectory, moduleInCacheName); if (!moduleInCache.exists()) { log.info("Caching repository " + repositoryUrl + " as " + moduleInCacheName); vcsSupport.checkout(repositoryUrl, moduleInCache, null, false, true); } else { log.info("Updating cached repository in " + moduleInCacheName); vcsSupport.update(moduleInCache, null, false, true); } vcsSupport.checkout(moduleInCache.getAbsolutePath(), targetDirectory, branch, recursive, false); vcsSupport.activate(repositoryUrl, targetDirectory); if (newName) { cacheMapping.put(normalizedUrl, moduleInCacheName); saveCacheMapping(); } }
@Override protected void execute(Pride pride, Module module) throws IOException { File moduleDir = pride.getModuleDirectory(module.getName()); String moduleBranch = explicitSwitchToBranch; if (Strings.isNullOrEmpty(moduleBranch)) { moduleBranch = module.getVcs().getSupport().getBranch(pride.getModuleDirectory(module.getName())); } module.getVcs().getSupport().update(moduleDir, moduleBranch, recursive, false); }