Search in sources :

Example 21 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class GitCommandTest method shouldGetTheCurrentBranchForTheCheckedOutRepo.

@Test
public void shouldGetTheCurrentBranchForTheCheckedOutRepo() throws IOException {
    gitLocalRepoDir = createTempWorkingDirectory();
    CommandLine gitCloneCommand = CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("clone");
    gitCloneCommand.withArg("--branch=" + BRANCH).withArg(new UrlArgument(gitFooBranchBundle.projectRepositoryUrl())).withArg(gitLocalRepoDir.getAbsolutePath());
    gitCloneCommand.run(inMemoryConsumer(), "");
    git = new GitCommand(null, gitLocalRepoDir, BRANCH, false, new HashMap<>(), null);
    assertThat(git.getCurrentBranch(), Is.is(BRANCH));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) CommandLine(com.thoughtworks.go.util.command.CommandLine) Test(org.junit.Test)

Example 22 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class GitCommandTest method shouldCloneFromMasterWhenNoBranchIsSpecified.

@Test
public void shouldCloneFromMasterWhenNoBranchIsSpecified() {
    InMemoryStreamConsumer output = inMemoryConsumer();
    git.clone(output, repoUrl);
    CommandLine commandLine = CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(gitLocalRepoDir);
    commandLine.run(output, "");
    assertThat(output.getStdOut(), Is.is("* master"));
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) Test(org.junit.Test)

Example 23 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class HgCommandTest method hg.

private CommandLine hg(File workingDir, String... arguments) {
    CommandLine hg = CommandLine.createCommandLine("hg").withArgs(arguments).withEncoding("utf-8");
    hg.setWorkingDir(workingDir);
    return hg;
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Example 24 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class HgCommandTest method commit.

private void commit(String message, File workingDir) {
    CommandLine hg = hg(workingDir, "ci", "-u", "cruise-test", "-m", message);
    String[] input = new String[] {};
    hg.runOrBomb(null, input);
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Example 25 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class HgCommandTest method latestRevisionOf.

private Revision latestRevisionOf() {
    CommandLine hg = hg(serverRepo, "log", "--limit", "1", "--template", "{node}");
    String[] input = new String[] {};
    return new StringRevision(hg.runOrBomb(null, input).outputAsString());
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Aggregations

CommandLine (com.thoughtworks.go.util.command.CommandLine)31 Test (org.junit.Test)16 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)6 ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)5 File (java.io.File)5 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 RunIf (com.googlecode.junit.ext.RunIf)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 ProcessOutputStreamConsumer (com.thoughtworks.go.util.command.ProcessOutputStreamConsumer)2 LinkedList (java.util.LinkedList)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 CheckedCommandLineException (com.thoughtworks.go.util.command.CheckedCommandLineException)1 CompositeConsumer (com.thoughtworks.go.util.command.CompositeConsumer)1 CruiseControlException (com.thoughtworks.go.util.command.CruiseControlException)1 ExecScript (com.thoughtworks.go.util.command.ExecScript)1 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)1 IOException (java.io.IOException)1