Search in sources :

Example 56 with CheckoutRules

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

the class AgentVcsSupportTest method short_lived_agent_auto_clone_existing_mirror.

@TestFor(issues = "TW-71416")
public void short_lived_agent_auto_clone_existing_mirror() throws Exception {
    final File remote = dataFile("repo_for_shallow_fetch.git");
    final VcsRootImpl root1 = createRoot(remote, "refs/heads/main");
    root1.addProperty(Constants.CHECKOUT_POLICY, AgentCheckoutPolicy.USE_MIRRORS.name());
    myVcsSupport.updateSources(root1, new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myTempFiles.createTempDir(), myBuild, false);
    final File mirror = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(remote));
    // mirror initialized
    assertFalse(FileUtil.isEmptyDir(mirror));
    myBuild.getAgentConfiguration().addConfigurationParameter(AgentMiscConstants.IS_EPHEMERAL_AGENT_PROP, "true");
    final File testFile = new File(myCheckoutDir, "test_file");
    final File shallowMarker = new File(myCheckoutDir, ".git/shallow");
    final VcsRootImpl root2 = createRoot(remote, "refs/heads/main");
    root2.addProperty(Constants.CHECKOUT_POLICY, AgentCheckoutPolicy.AUTO.name());
    myVcsSupport.updateSources(root2, new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, myBuild, false);
    assertFalse(shallowMarker.exists());
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) 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 57 with CheckoutRules

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

the class AgentVcsSupportTest method testDotInSubmoduleBranch.

@TestFor(issues = "TW-72198")
public void testDotInSubmoduleBranch() throws Exception {
    myRoot.addProperty(Constants.BRANCH_NAME, "TW-72198");
    myRoot.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), "fd704a963d073ae4a2284eb03699433e48792747", myCheckoutDir, myBuild, false);
    final File file = new File(myCheckoutDir, "submodule" + File.separator + "f.txt");
    assertTrue(file.exists());
    assertEquals("TW-72198", 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 58 with CheckoutRules

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

the class AgentVcsSupportTest method delete_url_insteadOf_from_config_when_switching_from_mirrors_to_alternates.

@TestFor(issues = "TW-67736")
public void delete_url_insteadOf_from_config_when_switching_from_mirrors_to_alternates() throws Exception {
    final GitVcsRoot root = new AgentGitVcsRoot(myBuilder.getMirrorManager(), myRoot, myTookenStorage);
    {
        final AgentRunningBuild build = createRunningBuild(map(PluginConfigImpl.USE_MIRRORS, "true"));
        myVcsSupport.updateSources(root.getOriginalRoot(), new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, build, false);
    }
    final File gitConfigFile = new File(myCheckoutDir, ".git" + File.separator + "config");
    then(FileUtil.loadTextAndClose(new FileReader(gitConfigFile))).contains("insteadOf");
    {
        final AgentRunningBuild build = createRunningBuild(map(PluginConfigImpl.USE_ALTERNATES, "true"));
        myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, build, false);
    }
    then(FileUtil.loadTextAndClose(new FileReader(gitConfigFile))).doesNotContain("insteadOf");
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) FileReader(java.io.FileReader) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Example 59 with CheckoutRules

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

the class AgentVcsSupportTest method testRespectSubmoduleBranch.

@TestFor(issues = "TW-71691")
public void testRespectSubmoduleBranch() throws Exception {
    myRoot.addProperty(Constants.BRANCH_NAME, "TW-71691");
    myRoot.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), "058ad5872851a5e8c6b8a665d4e058b21fed27df", myCheckoutDir, myBuild, false);
    final File file = new File(myCheckoutDir, "submodule" + File.separator + "f.txt");
    assertTrue(file.exists());
    assertEquals("TW-71691", 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 60 with CheckoutRules

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

the class AgentVcsSupportTest method should_do_fetch_if_ref_is_outdated.

@Test(dataProvider = "mirrors")
public void should_do_fetch_if_ref_is_outdated(Boolean useMirrors) throws Exception {
    AgentRunningBuild build = createRunningBuild(useMirrors);
    final File remote = myTempFiles.createTempDir();
    copyRepository(dataFile("repo_for_fetch.2.personal"), remote);
    VcsRootImpl masterRoot = createRoot(remote, "master");
    VcsRootImpl personalRoot = createRoot(remote, "personal");
    myVcsSupport.updateSources(personalRoot, new CheckoutRules(""), "d47dda159b27b9a8c4cee4ce98e4435eb5b17168@1303829462000", myCheckoutDir, build, false);
    myVcsSupport.updateSources(masterRoot, new CheckoutRules(""), "add81050184d3c818560bdd8839f50024c188586@1303829295000", myCheckoutDir, build, false);
    FileUtil.delete(remote);
    copyRepository(dataFile("repo_for_fetch.2"), remote);
    myVcsSupport.updateSources(masterRoot, new CheckoutRules(""), "d47dda159b27b9a8c4cee4ce98e4435eb5b17168@1303829462000", myCheckoutDir, build, false);
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) Test(org.testng.annotations.Test)

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