use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitCommandTest method shouldBombWhileRetrievingLatestModificationFromANonExistentRef.
@Test
public void shouldBombWhileRetrievingLatestModificationFromANonExistentRef() throws IOException {
expectedException.expect(CommandLineException.class);
expectedException.expectMessage("ambiguous argument 'origin/non-existent-branch': unknown revision or path not in the working tree.");
GitTestRepo remoteRepo = new GitTestRepo();
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);
command.latestModification();
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitCommandTest method shouldBombIfCheckedForModificationsSinceWithANonExistentRef.
@Test(expected = CommandLineException.class)
public void shouldBombIfCheckedForModificationsSinceWithANonExistentRef() throws IOException {
GitTestRepo remoteRepo = new GitTestRepo();
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()));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo 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");
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.git.GitTestRepo in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
updateTo(new GitMaterial(new GitTestRepo().projectRepositoryUrl(), true), new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
shouldBeRemoved.createNewFile();
assertThat(shouldBeRemoved.exists(), is(true));
String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
GitMaterial material = new GitMaterial(repositoryUrl, true);
updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
assertThat(localRepoFor(material).workingRepositoryUrl().forCommandline(), is(repositoryUrl));
assertThat(shouldBeRemoved.exists(), is(false));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff.
@Test
public void shouldConvertExistingRepoToFullRepoWhenShallowCloneIsOff() throws IOException {
String repositoryUrl = new GitTestRepo().projectRepositoryUrl();
GitMaterial shallowMaterial = new GitMaterial(repositoryUrl, true);
updateTo(shallowMaterial, new RevisionContext(REVISION_3), JobResult.Passed);
assertThat(localRepoFor(shallowMaterial).isShallow(), is(true));
GitMaterial fullMaterial = new GitMaterial(repositoryUrl, false);
updateTo(fullMaterial, new RevisionContext(REVISION_4), JobResult.Passed);
assertThat(localRepoFor(fullMaterial).isShallow(), is(false));
}
Aggregations