Search in sources :

Example 46 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class GitPatchTest method build_patch_several_roots.

@Test(dataProvider = "patchInSeparateProcess")
public void build_patch_several_roots(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    // A build configuration can have several VCS roots, TeamCity builds patches in them one by one
    // in unspecified order and then combines them into a single patch. That means a patch for
    // individual VCS root should never delete the root directory, because this action could delete
    // sources of another VCS root. Also patches should not contain an 'EXIT' command, otherwise
    // when agent applies a combined patch it will stop after first 'EXIT'.
    // patch8 is combination of patch1 and patch6
    setName("patch8");
    // patch1
    GitVcsSupport support = getSupport();
    VcsRoot root1 = getRoot("patch-tests", false);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PatchBuilderImpl builder = new PatchBuilderImpl(output);
    support.buildPatch(root1, null, "0dd03338d20d2e8068fbac9f24899d45d443df38", builder, CheckoutRules.DEFAULT);
    // patch6
    VcsRoot root2 = getRoot("rename-test", false);
    // pass an unknown fromRevision 'a...a' to ensure we don't remove the root dir if the fromRevision is not found
    support.buildPatch(root2, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "2eed4ae6732536f76a65136a606f635e8ada63b9", builder, CheckoutRules.DEFAULT);
    builder.close();
    checkPatchResult(output.toByteArray());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) PatchBuilderImpl(jetbrains.buildServer.vcs.patches.PatchBuilderImpl) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 47 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class GitPatchTest method checkPatch.

private void checkPatch(String name, @NotNull String branchName, @Nullable String fromVersion, @NotNull String toVersion, boolean enableSubmodules) throws IOException, VcsException {
    setName(name);
    GitVcsSupport support = getSupport();
    VcsRoot root = getRoot(branchName, enableSubmodules);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    PatchBuilderImpl builder = new PatchBuilderImpl(output);
    support.buildPatch(root, fromVersion, toVersion, builder, CheckoutRules.DEFAULT);
    builder.close();
    checkPatchResult(output.toByteArray());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) PatchBuilderImpl(jetbrains.buildServer.vcs.patches.PatchBuilderImpl) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 48 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class AutoCheckoutTest method several_roots.

@TestFor(issues = "TW-49786")
@Test(dataProvider = "severalRootsSetups")
public void several_roots(@NotNull Setup setup) throws Exception {
    myVcsSupport = vcsSupportWithRealGit();
    VcsRoot root1 = vcsRoot().withId(1).withFetchUrl("http://some.org/repo1.git").withAgentGitPath(getGitPath()).build();
    VcsRoot root2 = vcsRoot().withId(2).withFetchUrl("http://some.org/repo2.git").withAgentGitPath(getGitPath()).build();
    AgentRunningBuild build = runningBuild().addRootEntry(root1, setup.getCheckoutRules1()).addRootEntry(root2, setup.getCheckoutRules2()).build();
    AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules(setup.getCheckoutRules1()), build);
    AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules(setup.getCheckoutRules2()), build);
    if (setup.isShouldFail()) {
        then(canCheckout1.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root '" + root1.getName() + "' into the same directory as VCS root '" + root2.getName() + "'");
        then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root '" + root2.getName() + "' into the same directory as VCS root '" + root1.getName() + "'");
    } else {
        then(canCheckout1.getCanNotCheckoutReason()).isNull();
        then(canCheckout2.getCanNotCheckoutReason()).isNull();
    }
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentCheckoutAbility(jetbrains.buildServer.agent.vcs.AgentCheckoutAbility) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 49 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class BranchSupportTest method test.

/**
 * o ee886e4adb70fbe3bdc6f3f6393598b3f02e8009 (change1)
 * |
 * |
 * |  o 1391281d33a83a7205f2f05d3eb64c349c636e87 (change2)
 * |  |
 * | /
 * |/
 * o f3f826ce85d6dad25156b2d7550cedeb1a422f4c
 * |
 * |
 * |
 */
public void test() throws VcsException {
    VcsRoot originalRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
    VcsRoot substitutionRoot = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("personal-branch1").build();
    final String originalRootVersion = "3b9fbfbb43e7edfad018b482e15e7f93cca4e69f";
    final String substitutionRootVersion = "1391281d33a83a7205f2f05d3eb64c349c636e87";
    GitVcsSupport vcsSupport = gitSupport().withServerPaths(myServerPaths).build();
    List<ModificationData> changes = vcsSupport.collectChanges(originalRoot, originalRootVersion, substitutionRoot, substitutionRootVersion, CheckoutRules.DEFAULT);
    assertEquals(1, changes.size());
    assertEquals(substitutionRoot, changes.get(0).getVcsRootObject());
    assertEquals(substitutionRootVersion, changes.get(0).getVersion());
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) ModificationData(jetbrains.buildServer.vcs.ModificationData) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 50 with VcsRoot

use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.

the class BulkPatchBuilderTest method test_merged_patch.

@Test
public void test_merged_patch() throws Exception {
    final VcsRoot root = vcsRoot().withFetchUrl(GitUtils.toURL(myRepositoryDir)).withBranch("master").build();
    final ArrayList<String> log = new ArrayList<String>();
    final BulkPatchBuilder patcher = patcher(new PatchLogger() {

        public void log(@NotNull final String message) {
            log.add(message);
        }
    });
    runFullPatch(root, patcher);
    Assert.assertTrue(log.size() > 0);
}
Also used : BulkPatchBuilder(jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder) ArrayList(java.util.ArrayList) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test)

Aggregations

VcsRoot (jetbrains.buildServer.vcs.VcsRoot)59 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)25 TestFor (jetbrains.buildServer.util.TestFor)17 Test (org.testng.annotations.Test)16 GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)15 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)10 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)9 File (java.io.File)8 VcsException (jetbrains.buildServer.vcs.VcsException)8 URIish (org.eclipse.jgit.transport.URIish)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)3 NotNull (org.jetbrains.annotations.NotNull)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GitVersion (jetbrains.buildServer.buildTriggers.vcs.git.GitVersion)2 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)2 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)2 TeamCitySshKey (jetbrains.buildServer.ssh.TeamCitySshKey)2 BulkPatchBuilder (jetbrains.buildServer.vcs.BulkPatchService.BulkPatchBuilder)2 RepositoryStateData (jetbrains.buildServer.vcs.RepositoryStateData)2