Search in sources :

Example 1 with StringRevision

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

the class TfsSDKCommandTest method shouldReturnChangeSetsFromAPreviouslyKnownRevisionUptilTheLatest.

@Test
public void shouldReturnChangeSetsFromAPreviouslyKnownRevisionUptilTheLatest() throws Exception {
    Changeset[] changeSets = getChangeSets(42);
    when(client.queryHistory(eq(TFS_PROJECT), any(ChangesetVersionSpec.class), anyInt())).thenReturn(changeSets);
    TfsSDKCommand spy = spy(tfsCommand);
    doReturn(null).when(spy).getModifiedFiles(changeSets[0]);
    List<Modification> modifications = spy.modificationsSince(null, new StringRevision("2"));
    assertThat(modifications.isEmpty(), is(false));
    verify(client, times(2)).queryHistory(eq(TFS_PROJECT), any(ChangesetVersionSpec.class), anyInt());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ChangesetVersionSpec(com.microsoft.tfs.core.clients.versioncontrol.specs.version.ChangesetVersionSpec) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Changeset(com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Changeset) Test(org.junit.Test)

Example 2 with StringRevision

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

the class GitCommand method fetchAndResetToHead.

public void fetchAndResetToHead(ProcessOutputStreamConsumer outputStreamConsumer) {
    fetch(outputStreamConsumer);
    resetWorkingDir(outputStreamConsumer, new StringRevision(remoteBranch()));
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision)

Example 3 with StringRevision

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

the class GitMaterialTest method shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo.

@Test
public void shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    StringRevision revision = new StringRevision("origin/master");
    gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(new File(workingDir, "sub1"), exists());
    submoduleRepos.removeSubmodule("sub1");
    outputStreamConsumer = inMemoryConsumer();
    gitMaterial.updateTo(outputStreamConsumer, workingDir, new RevisionContext(revision), new TestSubprocessExecutionContext());
    assertThat(new File(workingDir, "sub1"), not(exists()));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 4 with StringRevision

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

the class GitSubmoduleRepos 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 5 with StringRevision

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

the class GitCommand method fetchAndResetToHead.

public void fetchAndResetToHead(ConsoleOutputStreamConsumer outputStreamConsumer) {
    fetch(outputStreamConsumer);
    resetWorkingDir(outputStreamConsumer, new StringRevision(remoteBranch()));
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision)

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