Search in sources :

Example 6 with GitTestRepo

use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.

the class GitCommandTest method shouldReturnNothingForModificationsSinceIfARebasedCommitSHAIsPassed.

@Test
public void shouldReturnNothingForModificationsSinceIfARebasedCommitSHAIsPassed() 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.addFileAndAmend("foo", "amendedCommit").get(0);
    assertThat(command.modificationsSince(new StringRevision(modification.getRevision())).isEmpty(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.Test)

Example 7 with GitTestRepo

use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.

the class MixedMultipleMaterialsTest method createRepo.

@Before
public void createRepo() throws IOException {
    svnRepo = new SvnTestRepo(temporaryFolder);
    hgRepo = new HgTestRepo(temporaryFolder);
    gitRepo = new GitTestRepo(temporaryFolder);
    pipelineDir = temporaryFolder.newFolder();
}
Also used : GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) Before(org.junit.Before)

Example 8 with GitTestRepo

use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldLogRepoInfoToConsoleOutWithoutFolder.

@Test
public void shouldLogRepoInfoToConsoleOutWithoutFolder() throws Exception {
    String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
    GitMaterial material = new GitMaterial(repositoryUrl, false);
    updateTo(material, new RevisionContext(REVISION_1), JobResult.Passed);
    assertThat(console.output(), containsString(format("Start updating %s at revision %s from %s", "files", REVISION_1.getRevision(), repositoryUrl)));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 9 with GitTestRepo

use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.

the class GitMaterialUpdaterTest method cloneWithDeepWorkingDir.

@Test
public void cloneWithDeepWorkingDir() throws Exception {
    GitMaterial material = new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), "", "foo/bar/baz", true);
    updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
    assertThat(new File(workingDir, "foo/bar/baz/build.xml").exists(), is(true));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) File(java.io.File) Test(org.junit.Test)

Example 10 with GitTestRepo

use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.

the class GitMaterialUpdaterTest method shouldCleanDirtyFilesUponUpdate.

@Test
public void shouldCleanDirtyFilesUponUpdate() throws IOException {
    String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
    GitMaterial material = new GitMaterial(repositoryUrl, true);
    updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
    File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
    assertTrue(shouldBeRemoved.createNewFile());
    updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
    assertThat(shouldBeRemoved.exists(), is(false));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Aggregations

GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)25 Test (org.junit.Test)20 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)9 Modification (com.thoughtworks.go.domain.materials.Modification)7 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)7 File (java.io.File)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Before (org.junit.Before)5 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 HgTestRepo (com.thoughtworks.go.helper.HgTestRepo)1 SvnTestRepo (com.thoughtworks.go.helper.SvnTestRepo)1 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)1