Search in sources :

Example 31 with CheckoutRules

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

the class LatestAcceptedRevisionTest method traverse_through_merges_looking_for_interesting_commit.

public void traverse_through_merges_looking_for_interesting_commit() throws VcsException, IOException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/master", "6d8cc5e06db390a20f5b2bf278206a0ec47f05dc");
    Set<String> visited = new HashSet<>();
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/subDir"), "6ff32b16fe485e7a0a1e209bf10987e1ad46292e", Collections.emptySet(), visited);
    then(rev).isEqualTo("be6e6b68e84b5aec8a022a8b2d740ed39a7c63b9");
    then(visited).containsOnly("6ff32b16fe485e7a0a1e209bf10987e1ad46292e", "eea4a3e48901ba036998c9fe0afdc78cc8a05a33", "1330f191b990a389459e28f8754c913e9b417c93", "75c9325d5b129f299fba8567f0fd7f599d336e8f", "be6e6b68e84b5aec8a022a8b2d740ed39a7c63b9");
    visited.clear();
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/TestFile4.java"), "6ff32b16fe485e7a0a1e209bf10987e1ad46292e", Collections.emptySet(), visited);
    then(rev).isEqualTo("40224a053e16145562d1befa3d0a127c54f5dbff");
    then(visited).containsOnly("6ff32b16fe485e7a0a1e209bf10987e1ad46292e", "ce92302a768ce0763e83aebf8c0e16e102c8d06b", "d036d012385a762568a474b57337b9cf398b96e0", "40224a053e16145562d1befa3d0a127c54f5dbff");
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) HashSet(java.util.HashSet)

Example 32 with CheckoutRules

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

the class MapFullPathTest method bulk.

public void bulk() throws Exception {
    // clone repository for myRoot and root3
    RepositoryStateData state0 = RepositoryStateData.createSingleVersionState("a7274ca8e024d98c7d59874f19f21d26ee31d41d");
    RepositoryStateData state1 = myGit.getCurrentState(myRoot);
    myGit.getCollectChangesPolicy().collectChanges(myRoot, state0, state1, CheckoutRules.DEFAULT);
    // tracks same repo as myRoot1
    VcsRoot root3 = vcsRoot().withId(3).withFetchUrl(myRemoteRepositoryDir.getAbsolutePath()).build();
    // tracks same repo as myRoot2
    VcsRoot root4 = vcsRoot().withId(4).withFetchUrl(myRemoteRepositoryDir2.getAbsolutePath()).build();
    List<Boolean> result = myGit.checkSuitable(asList(new VcsRootEntry(myRoot, new CheckoutRules("-:dir1")), new VcsRootEntry(myRoot, new CheckoutRules("+:dir1")), new VcsRootEntry(myRoot, new CheckoutRules("+:dir2")), new VcsRootEntry(myRoot2, new CheckoutRules("+:dir2")), new VcsRootEntry(root3, new CheckoutRules("+:dir1")), new VcsRootEntry(root4, new CheckoutRules("+:dir4")), new VcsRootEntry(root3, new CheckoutRules("+:dir5")), new VcsRootEntry(root4, new CheckoutRules("+:dir6"))), asList(// affects root and root3
    "a7274ca8e024d98c7d59874f19f21d26ee31d41d-add81050184d3c818560bdd8839f50024c188586||dir1/text1.txt", // affects no repo
    "abababababababababababababababababababab||."));
    then(result).containsExactly(false, true, false, false, true, false, false, false);
}
Also used : RepositoryStateData(jetbrains.buildServer.vcs.RepositoryStateData) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRootEntry(jetbrains.buildServer.vcs.VcsRootEntry) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 33 with CheckoutRules

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

the class GitPatchTest method submodules_and_checkout_rules3.

@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules3(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = getRoot("sub-submodule", true);
    checkPatch(root, "submodules_and_checkout_rules3", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("-:first-level-submodule/sub-sub/file.txt"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 34 with CheckoutRules

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

the class GitPatchTest method submodules_and_checkout_rules.

@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = getRoot("sub-submodule", true);
    checkPatch(root, "submodules_and_checkout_rules", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("+:first-level-submodule"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 35 with CheckoutRules

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

the class GitPatchTest method build_patch_should_respect_autocrlf.

@TestFor(issues = "TW-16530")
@Test(dataProvider = "patchInSeparateProcess")
public void build_patch_should_respect_autocrlf(boolean patchInSeparateProcess) throws Exception {
    myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
    VcsRoot root = vcsRoot().withAutoCrlf(true).withFetchUrl(myMainRepositoryDir.getAbsolutePath()).build();
    setExpectedSeparator("\r\n");
    checkPatch(root, "patch-eol", null, "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", new CheckoutRules("-:dir"));
    String content = new String(getSupport().getContentProvider().getContent("readme.txt", root, "465ad9f630e451b9f2b782ffb09804c6a98c4bb9"));
    assertEquals(content, "Test repository for teamcity.change 1\r\nadd feature\r\n");
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)71 File (java.io.File)29 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)29 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)25 Test (org.testng.annotations.Test)23 TestFor (jetbrains.buildServer.util.TestFor)21 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)13 GitVcsSupport (jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport)10 AgentCheckoutAbility (jetbrains.buildServer.agent.vcs.AgentCheckoutAbility)7 VcsException (jetbrains.buildServer.vcs.VcsException)6 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)5 FileReader (java.io.FileReader)4 Method (java.lang.reflect.Method)4 FetchCommand (jetbrains.buildServer.buildTriggers.vcs.git.command.FetchCommand)4 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)4 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)3 AfterMethod (org.testng.annotations.AfterMethod)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 ArrayList (java.util.ArrayList)2 BuildTriggerDescriptor (jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor)2