Search in sources :

Example 11 with GitTestRepo

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

the class MaterialDatabaseUpdaterIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    testRepo = new GitTestRepo();
    MaterialService slowMaterialService = new MaterialServiceWhichSlowsDownFirstTimeModificationCheck(materialRepository, goConfigService, securityService, packageRepositoryExtension, scmExtension);
    LegacyMaterialChecker materialChecker = new LegacyMaterialChecker(slowMaterialService, subprocessExecutionContext);
    ScmMaterialUpdater scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, slowMaterialService);
    transactionTemplateWithInvocationCount = new TransactionTemplateWithInvocationCount(transactionTemplate);
    updater = new MaterialDatabaseUpdater(materialRepository, serverHealthService, transactionTemplateWithInvocationCount, dependencyMaterialUpdater, scmMaterialUpdater, packageMaterialUpdater, pluggableSCMMaterialUpdater, materialExpansionService);
}
Also used : MaterialService(com.thoughtworks.go.server.service.MaterialService) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) Before(org.junit.Before)

Example 12 with GitTestRepo

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

the class GitCommandTest method shouldRetrieveFilenameForInitialRevision.

@Test
public void shouldRetrieveFilenameForInitialRevision() throws IOException {
    GitTestRepo testRepo = new GitTestRepo(GitTestRepo.GIT_SUBMODULE_REF_BUNDLE);
    GitCommand gitCommand = new GitCommand(null, testRepo.gitRepository(), GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
    Modification modification = gitCommand.latestModification().get(0);
    assertThat(modification.getModifiedFiles().size(), is(1));
    assertThat(modification.getModifiedFiles().get(0).getFileName(), is("remote.txt"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo)

Example 13 with GitTestRepo

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

the class GitCommandTest method shouldBombIfCheckedForModificationsSinceWithASHAThatNoLongerExists.

@Test(expected = CommandLineException.class)
public void shouldBombIfCheckedForModificationsSinceWithASHAThatNoLongerExists() 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, "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()));
}
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)

Example 14 with GitTestRepo

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

the class GitCommandTest method setup.

@Before
public void setup() throws Exception {
    gitRepo = new GitTestRepo();
    gitLocalRepoDir = createTempWorkingDirectory();
    git = new GitCommand(null, gitLocalRepoDir, GitMaterialConfig.DEFAULT_BRANCH, false, new HashMap<>(), null);
    repoLocation = gitRepo.gitRepository();
    repoUrl = gitRepo.projectRepositoryUrl();
    InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
    int returnCode = git.cloneWithNoCheckout(outputStreamConsumer, repoUrl);
    if (returnCode > 0) {
        fail(outputStreamConsumer.getAllOutput());
    }
    gitFooBranchBundle = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH);
    initMocks(this);
}
Also used : GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo)

Example 15 with GitTestRepo

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

the class GitCommandTest method shouldReturnTheRebasedCommitForModificationsSinceTheRevisionBeforeRebase.

@Test
public void shouldReturnTheRebasedCommitForModificationsSinceTheRevisionBeforeRebase() 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, "master", false, new HashMap<>(), null);
    Modification modification = remoteRepo.addFileAndAmend("foo", "amendedCommit").get(0);
    assertThat(command.modificationsSince(REVISION_4).get(0), is(modification));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo)

Aggregations

GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)25 Test (org.junit.Test)13 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)4 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 MaterialService (com.thoughtworks.go.server.service.MaterialService)1