Search in sources :

Example 16 with InMemoryStreamConsumer

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);
}
Also used : InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer)

Example 17 with InMemoryStreamConsumer

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);
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File)

Example 18 with InMemoryStreamConsumer

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);
}
Also used : NamedProcessTag(com.thoughtworks.go.util.NamedProcessTag) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer)

Example 19 with InMemoryStreamConsumer

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);
    }
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) File(java.io.File)

Example 20 with InMemoryStreamConsumer

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);
}
Also used : GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) Before(org.junit.Before)

Aggregations

InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)31 Test (org.junit.Test)17 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)8 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)7 File (java.io.File)7 StringContains.containsString (org.hamcrest.core.StringContains.containsString)7 Test (org.junit.jupiter.api.Test)5 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)4 CommandLine (com.thoughtworks.go.util.command.CommandLine)4 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)2 P4Client (com.thoughtworks.go.domain.materials.perforce.P4Client)2 IOException (java.io.IOException)2 SubprocessExecutionContext (com.thoughtworks.go.config.materials.SubprocessExecutionContext)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1 PluggableSCMMaterialAgent (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent)1