public void updateTo(ConsoleOutputStreamConsumer outputStreamConsumer, File baseDir, RevisionContext revisionContext, final SubprocessExecutionContext execCtx) { Revision revision = revisionContext.getLatestRevision(); try { outputStreamConsumer.stdOutput(format("[%s] Start updating %s at revision %s from %s", GoConstants.PRODUCT_NAME, updatingTarget(), revision.getRevision(), url)); File workingDir = execCtx.isServer() ? baseDir : workingdir(baseDir); GitCommand git = git(outputStreamConsumer, workingDir, revisionContext.numberOfModifications() + 1, execCtx); git.fetch(outputStreamConsumer); unshallowIfNeeded(git, outputStreamConsumer, revisionContext.getOldestRevision(), baseDir); git.resetWorkingDir(outputStreamConsumer, revision); outputStreamConsumer.stdOutput(format("[%s] Done.\n", GoConstants.PRODUCT_NAME)); } catch (Exception e) { bomb(e); } }
public BuildCommand updateTo(String baseDir, RevisionContext revisionContext) { Revision revision = revisionContext.getLatestRevision(); String workingDir = material.workingdir(new File(baseDir)).getPath(); UrlArgument url = material.getUrlArgument(); return compose( echoWithPrefix("Start updating %s at revision %s from %s", material.updatingTarget(), revision.getRevision(), url.forDisplay()), secret(url.forCommandline(), url.forDisplay()), cloneIfNeeded(workingDir, revisionContext.numberOfModifications() + 1), fetchRemote(workingDir), unshallowIfNeeded(workingDir, revision, new Integer[]{GitMaterial.UNSHALLOW_TRYOUT_STEP, Integer.MAX_VALUE}), resetWorkingCopy(workingDir, revision), echoWithPrefix("Done.\n")); }