use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldOutputSubmoduleRevisionsAfterUpdate.
@Test
public void shouldOutputSubmoduleRevisionsAfterUpdate() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial material = new GitMaterial(submoduleRepos.projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Passed);
Matcher matcher = Pattern.compile(".*^\\s[a-f0-9A-F]{40} sub1 \\(heads/master\\)$.*", Pattern.MULTILINE | Pattern.DOTALL).matcher(console.output());
assertThat(matcher.matches(), Matchers.is(true));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldBombForFetchAndResetWhenSubmoduleUpdateFails.
@Test
public void shouldBombForFetchAndResetWhenSubmoduleUpdateFails() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
File submoduleFolder = submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitMaterial material = new GitMaterial(submoduleRepos.projectRepositoryUrl(), true);
FileUtils.deleteDirectory(submoduleFolder);
assertThat(submoduleFolder.exists(), Matchers.is(false));
updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Failed);
assertThat(console.output(), // git on windows prints full submodule paths
new RegexMatcher(String.format("[Cc]lone of '%s' into submodule path '((.*)[\\/])?sub1' failed", Pattern.quote(submoduleFolder.getAbsolutePath()))));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank.
/* This is to test the functionality of the private method isRepositoryChanged() */
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenBranchIsBlank() throws Exception {
String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
GitMaterial material = new GitMaterial(repositoryUrl, false);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
FileUtils.writeStringToFile(shouldNotBeRemoved, "Text file", UTF_8);
GitMaterial material1 = new GitMaterial(repositoryUrl, " ");
updateTo(material1, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenBranchChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenBranchChanges() throws Exception {
GitTestRepo repoWithBranch = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, "foo", temporaryFolder);
GitMaterial material = new GitMaterial(repoWithBranch.projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
InMemoryStreamConsumer output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* master"));
GitMaterial material1 = new GitMaterial(repoWithBranch.projectRepositoryUrl(), "foo", null, true);
updateTo(material1, new RevisionContext(new StringRevision("origin/foo")), JobResult.Passed);
output = inMemoryConsumer();
CommandLine.createCommandLine("git").withEncoding("UTF-8").withArg("branch").withWorkingDir(workingDir).run(output, "");
assertThat(output.getStdOut(), Is.is("* foo"));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame.
@Test
public void shouldNotDeleteAndRecheckoutDirectoryWhenUrlSame() throws Exception {
GitMaterial material = new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), true);
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldNotBeRemoved = new File(new File(workingDir, ".git"), "shouldNotBeRemoved");
FileUtils.writeStringToFile(shouldNotBeRemoved, "gundi", UTF_8);
assertThat(shouldNotBeRemoved.exists(), is(true));
updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
assertThat("Should not have deleted whole folder", shouldNotBeRemoved.exists(), is(true));
}
Aggregations