use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class ScmMaterial method checkout.
public void checkout(File baseDir, Revision revision, SubprocessExecutionContext execCtx) {
InMemoryStreamConsumer output = ProcessOutputStreamConsumer.inMemoryConsumer();
this.updateTo(output, baseDir, new RevisionContext(revision), execCtx);
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class MaterialRevisionTest method checkInFiles.
private void checkInFiles(HgMaterial hgMaterial, String... fileNames) throws Exception {
final File localDir = TempDirUtils.createRandomDirectoryIn(tempDir).toFile();
InMemoryStreamConsumer consumer = inMemoryConsumer();
Revision revision = latestRevision(hgMaterial, workingFolder, new TestSubprocessExecutionContext());
hgMaterial.updateTo(consumer, localDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
for (String fileName : fileNames) {
File file = new File(localDir, fileName);
FileUtils.writeStringToFile(file, "", UTF_8);
hgMaterial.add(localDir, consumer, file);
}
hgMaterial.commit(localDir, consumer, "Adding a new file.", "TEST");
hgMaterial.push(localDir, consumer);
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitTestRepo method cloneBundleToFolder.
private void cloneBundleToFolder(File from, File workingDir) {
GitCommand git = git(workingDir);
InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
int returnValue = git.clone(outputStreamConsumer, from.getAbsolutePath());
if (returnValue != 0) {
throw new RuntimeException(String.format("[ERROR] Failed to clone. URL [%s] exit value [%d] output [%s]", from.getAbsolutePath(), returnValue, outputStreamConsumer.getAllOutput()));
}
createCommandLine("git").withEncoding("UTF-8").withWorkingDir(workingDir).withArgs("config", "user.name", "go_test").runOrBomb(true, new NamedProcessTag("git_config"));
createCommandLine("git").withEncoding("UTF-8").withWorkingDir(workingDir).withArgs("config", "user.email", "go_test@go_test.me").runOrBomb(true, new NamedProcessTag("git_config"));
createCommandLine("git").withEncoding("UTF-8").withWorkingDir(workingDir).withArgs("config", "commit.gpgSign", "false").runOrBomb(true, new NamedProcessTag("git_config"));
git.fetchAndResetToHead(outputStreamConsumer, false);
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GarageService method gc.
public void gc(HttpLocalizedOperationResult result) {
CommandLine gitCheck = getGit().withArg("--version");
InMemoryStreamConsumer consumer = new InMemoryStreamConsumer();
if (execute(gitCheck, consumer, result)) {
File configRepoDir = systemEnvironment.getConfigRepoDir();
CommandLine gc = getGit().withArg("gc").withWorkingDir(configRepoDir);
execute(gc, consumer, result);
}
}
use of com.thoughtworks.go.util.command.InMemoryStreamConsumer in project gocd by gocd.
the class GitCommandTest method setup.
@Before
public void setup() throws Exception {
gitRepo = new GitTestRepo(temporaryFolder);
gitLocalRepoDir = createTempWorkingDirectory();
git = new GitCommand(null, gitLocalRepoDir, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
repoLocation = gitRepo.gitRepository();
repoUrl = gitRepo.projectRepositoryUrl();
InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
int returnCode = git.cloneWithNoCheckout(outputStreamConsumer, repoUrl);
if (returnCode > 0) {
fail(outputStreamConsumer.getAllOutput());
}
gitFooBranchBundle = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH, temporaryFolder);
initMocks(this);
}
Aggregations