use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitCommandTest method shouldBombIfCheckedForModificationsSinceWithASHAThatNoLongerExists.
@Test(expected = CommandLineException.class)
public void shouldBombIfCheckedForModificationsSinceWithASHAThatNoLongerExists() throws IOException {
GitTestRepo remoteRepo = new GitTestRepo(temporaryFolder);
executeOnGitRepo("git", "remote", "rm", "origin");
executeOnGitRepo("git", "remote", "add", "origin", remoteRepo.projectRepositoryUrl());
GitCommand command = new GitCommand(remoteRepo.createMaterial().getFingerprint(), gitLocalRepoDir, "master", false, new HashMap<>(), null);
Modification modification = remoteRepo.checkInOneFile("foo", "Adding a commit").get(0);
remoteRepo.addFileAndAmend("bar", "amendedCommit");
command.modificationsSince(new StringRevision(modification.getRevision()));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitCommandTest method shouldBombForResetWorkingDirWhenSubmoduleUpdateFails.
@Test
public void shouldBombForResetWorkingDirWhenSubmoduleUpdateFails() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
File submoduleFolder = submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitCommand gitWithSubmodule = new GitCommand(null, createTempWorkingDirectory(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
gitWithSubmodule.clone(inMemoryConsumer(), submoduleRepos.mainRepo().getUrl());
FileUtils.deleteDirectory(submoduleFolder);
assertThat(submoduleFolder.exists(), is(false));
try {
gitWithSubmodule.resetWorkingDir(new SysOutStreamConsumer(), new StringRevision("HEAD"));
fail("should have failed for non 0 return code");
} catch (Exception e) {
assertThat(e.getMessage(), 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 GitCommandTest method shouldBombForResettingFailure.
@Test
public void shouldBombForResettingFailure() throws IOException {
try {
git.resetWorkingDir(new SysOutStreamConsumer(), new StringRevision("abcdef"));
fail("should have failed for non 0 return code");
} catch (Exception e) {
assertThat(e.getMessage(), is(String.format("git reset failed for [%s]", gitLocalRepoDir)));
}
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitCommandTest method shouldOutputSubmoduleRevisionsAfterUpdate.
@Test
public void shouldOutputSubmoduleRevisionsAfterUpdate() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
submoduleRepos.addSubmodule(SUBMODULE, "sub1");
GitCommand gitWithSubmodule = new GitCommand(null, createTempWorkingDirectory(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
gitWithSubmodule.clone(inMemoryConsumer(), submoduleRepos.mainRepo().getUrl());
InMemoryStreamConsumer outConsumer = new InMemoryStreamConsumer();
gitWithSubmodule.resetWorkingDir(outConsumer, new StringRevision("HEAD"));
Matcher matcher = Pattern.compile(".*^\\s[a-f0-9A-F]{40} sub1 \\(heads/master\\)$.*", Pattern.MULTILINE | Pattern.DOTALL).matcher(outConsumer.getAllOutput());
assertThat(matcher.matches(), is(true));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitCommandTest method shouldBombIfCheckedForModificationsSinceWithANonExistentRef.
@Test(expected = CommandLineException.class)
public void shouldBombIfCheckedForModificationsSinceWithANonExistentRef() throws IOException {
GitTestRepo remoteRepo = new GitTestRepo(temporaryFolder);
executeOnGitRepo("git", "remote", "rm", "origin");
executeOnGitRepo("git", "remote", "add", "origin", remoteRepo.projectRepositoryUrl());
GitCommand command = new GitCommand(remoteRepo.createMaterial().getFingerprint(), gitLocalRepoDir, "non-existent-branch", false, new HashMap<>(), null);
Modification modification = remoteRepo.checkInOneFile("foo", "Adding a commit").get(0);
command.modificationsSince(new StringRevision(modification.getRevision()));
}
Aggregations