Search in sources :

Example 26 with CheckoutRules

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

the class AgentVcsSupportTest method testSubmmoduleCommitReferencedByTag_mirrors.

@TestFor(issues = "TW-65043")
public void testSubmmoduleCommitReferencedByTag_mirrors() throws Exception {
    myRoot.addProperty(Constants.BRANCH_NAME, "TW-65043");
    myRoot.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), "4be4cc77ac427ecabf6ca53a76e33f6e186db6f2", myCheckoutDir, myBuild, false);
    final File file = new File(myCheckoutDir, "submodule" + File.separator + "file.txt");
    assertTrue(file.exists());
    assertEquals("TW-65043", FileUtil.readText(file, "UTF-8").trim());
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Example 27 with CheckoutRules

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

the class AgentVcsSupportTest method checkout_tag_after_branch.

public void checkout_tag_after_branch() throws Exception {
    myRoot.addProperty(Constants.BRANCH_NAME, "sub-submodule");
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, myBuild, false);
    myRoot.addProperty(Constants.BRANCH_NAME, "refs/tags/v1.0");
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitUtils.makeVersion("465ad9f630e451b9f2b782ffb09804c6a98c4bb9", 1289483394000L), myCheckoutDir, myBuild, false);
    Repository r = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
    Ref headRef = r.exactRef("HEAD");
    assertEquals("465ad9f630e451b9f2b782ffb09804c6a98c4bb9", headRef.getObjectId().name());
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules)

Example 28 with CheckoutRules

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

the class LatestAcceptedRevisionTest method merge_commit_tree_does_not_have_difference_with_parents.

/**
 * This test is for the following case:
 * <pre>
 *       o m3
 *     /  \
 * m1 o    o m2
 *    | \/ |
 * c1 o   o c2
 *    |  /
 *    o
 * </pre>
 * Here m1 and m2 have the same trees, so when m3 is created there is no diff between m3 & m1 and m3 & m2.
 * So although both c1 & c2 change interesting files we won't see a diff in trees in m3 comparing to its parents and
 * can think that nothing interesting was changed, while this is not true.
 */
public void merge_commit_tree_does_not_have_difference_with_parents() throws VcsException, IOException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/master", "6399724fac6ec9c62e8795fc037ad385e873911f");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
    // m3 is 6394695f179d87f7f5fc712e12dfac0ed0d98652
    then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File6.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
    then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File7.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
    then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/TestFile5.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
    then(rev).isEqualTo("8fc8c2a8baf37a71a2cdd0c2b0cd1eedfd1649e8");
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 29 with CheckoutRules

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

the class LatestAcceptedRevisionTest method branch_merged_to_master.

public void branch_merged_to_master() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/master", "b304522994197be5f336d58cc34edc11cbda095e");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "b304522994197be5f336d58cc34edc11cbda095e", Collections.emptySet());
    then(rev).isEqualTo("bb6ab65d23fa0ffbaa61d44c8241f127cf0f323f");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test"), "b304522994197be5f336d58cc34edc11cbda095e", Collections.emptySet());
    then(rev).isEqualTo("b265fd1608fe17f912a031312e1efc758c4e8a35");
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

Example 30 with CheckoutRules

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

the class LatestAcceptedRevisionTest method test_include_all_exclude_all.

public void test_include_all_exclude_all() throws IOException, VcsException {
    GitVcsSupport support = git();
    VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
    ensureFetchPerformed(support, root, "refs/heads/master", "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf");
    String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:."), "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf", Collections.emptySet());
    then(rev).isEqualTo("bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf");
    rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("-:."), "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf", Collections.emptySet());
    then(rev).isNull();
}
Also used : GitVcsSupport(jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot)

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