Search in sources :

Example 21 with StringRevision

use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.

the class P4MaterialTestBase method shouldLogRepoInfoToConsoleOutWithoutFolder.

@Test
void shouldLogRepoInfoToConsoleOutWithoutFolder() {
    P4Material p4Material = p4Fixture.material(VIEW);
    updateMaterial(p4Material, new StringRevision("2"));
    String message = format("Start updating %s at revision %s from %s", "files", "2", p4Material.getUrl());
    assertThat(outputconsumer.getStdOut()).contains(message);
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.jupiter.api.Test)

Example 22 with StringRevision

use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.

the class P4MaterialTestBase method shouldCleanOutRepoWhenViewChanges.

@Test
void shouldCleanOutRepoWhenViewChanges() {
    P4Material p4Material = p4Fixture.material(VIEW);
    updateMaterial(p4Material, new StringRevision("2"));
    assertThat(clientFolder.listFiles()).hasSize(8);
    P4Material otherMaterial = p4Fixture.material("//depot/lib/... //something/...");
    updateMaterial(otherMaterial, new StringRevision("2"));
    assertThat(clientFolder.listFiles()).hasSize(2);
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.jupiter.api.Test)

Example 23 with StringRevision

use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.

the class GitRepoContainingSubmodule method changeSubmoduleUrl.

public void changeSubmoduleUrl(String submoduleName) throws Exception {
    File newSubmodule = createRepo("new-submodule");
    addAndCommitNewFile(newSubmodule, "new", "make a commit");
    git(remoteRepoDir).changeSubmoduleUrl(submoduleName, newSubmodule.getAbsolutePath());
    git(remoteRepoDir).submoduleSync();
    git(new File(remoteRepoDir, "local-submodule")).fetch(inMemoryConsumer());
    git(new File(remoteRepoDir, "local-submodule")).resetHard(inMemoryConsumer(), new StringRevision("origin/master"));
    git(remoteRepoDir).add(new File(".gitmodules"));
    git(remoteRepoDir).add(new File("local-submodule"));
    git(remoteRepoDir).commit("change submodule url");
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File)

Example 24 with StringRevision

use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.

the class BackupServiceIntegrationTest method shouldBackupConfigRepository.

@Test
public void shouldBackupConfigRepository(@TempDir Path temporaryFolder) throws IOException {
    configHelper.addPipeline("too-unique-to-be-present", "stage-name");
    ServerBackup backup = backupService.startBackup(admin);
    assertThat(backup.isSuccessful(), is(true));
    assertThat(backup.getMessage(), is("Backup was generated successfully."));
    File repoZip = backedUpFile("config-repo.zip");
    File repoDir = TempDirUtils.createTempDirectoryIn(temporaryFolder, "expanded-config-repo-backup").toFile();
    new ZipUtil().unzip(repoZip, repoDir);
    File cloneDir = TempDirUtils.createTempDirectoryIn(temporaryFolder, "cloned-config-repo-backup").toFile();
    GitMaterial git = new GitMaterial(repoDir.getAbsolutePath());
    List<Modification> modifications = git.latestModification(cloneDir, subprocessExecutionContext);
    String latestChangeRev = modifications.get(0).getRevision();
    git.checkout(cloneDir, new StringRevision(latestChangeRev), subprocessExecutionContext);
    assertThat(FileUtils.readFileToString(new File(cloneDir, "cruise-config.xml"), UTF_8).indexOf("too-unique-to-be-present"), greaterThan(0));
    StringRevision revision = new StringRevision(latestChangeRev + "~1");
    git.updateTo(new InMemoryStreamConsumer(), cloneDir, new RevisionContext(revision), subprocessExecutionContext);
    assertThat(FileUtils.readFileToString(new File(cloneDir, "cruise-config.xml"), UTF_8).indexOf("too-unique-to-be-present"), is(-1));
    // Workaround issue with deletion of symlinks via JUnit TempDir by pre-deleting
    FileUtils.deleteQuietly(cloneDir);
}
Also used : ServerBackup(com.thoughtworks.go.server.domain.ServerBackup) Modification(com.thoughtworks.go.domain.materials.Modification) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) Test(org.junit.jupiter.api.Test)

Example 25 with StringRevision

use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.

the class ModificationsTest method shouldReturnRevisionsWithoutSpecifiedRevision.

@Test
public void shouldReturnRevisionsWithoutSpecifiedRevision() {
    final Modification modification1 = new Modification(new Date(), "1", "MOCK_LABEL-12", null);
    final Modification modification2 = new Modification(new Date(), "2", "MOCK_LABEL-12", null);
    List<Modification> modifications = new ArrayList<>();
    modifications.add(modification1);
    modifications.add(modification2);
    List<Modification> filtered = Modifications.filterOutRevision(modifications, new StringRevision("1"));
    assertThat(filtered.size(), is(1));
    assertThat(filtered.get(0), is(modification2));
}
Also used : ArrayList(java.util.ArrayList) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)65 Test (org.junit.Test)35 File (java.io.File)31 Test (org.junit.jupiter.api.Test)23 Modification (com.thoughtworks.go.domain.materials.Modification)17 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)17 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)11 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)7 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)6 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 StringContains.containsString (org.hamcrest.core.StringContains.containsString)5 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)4 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)3 JsonValue (com.thoughtworks.go.util.JsonValue)3 Changeset (com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Changeset)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 SysOutStreamConsumer (com.thoughtworks.go.mail.SysOutStreamConsumer)2