Search in sources :

Example 21 with CheckoutRules

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

the class AgentVcsSupportTest method switch_from_alternates_to_shallow_clone_from_mirror.

@Test
@TestFor(issues = "TW-71077")
public void switch_from_alternates_to_shallow_clone_from_mirror() throws Exception {
    final File remote = dataFile("repo_for_shallow_fetch.git");
    final File testFile = new File(myCheckoutDir, "test_file");
    final File shallowMarker = new File(myCheckoutDir, ".git/shallow");
    final AgentRunningBuild build1 = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.USE_ALTERNATES, "true"));
    myVcsSupport.updateSources(createRoot(remote, "refs/heads/main"), new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, build1, false);
    assertFalse(shallowMarker.exists());
    FileUtil.writeFile(testFile, "test text", StandardCharsets.UTF_8);
    assertTrue(testFile.isFile());
    final AgentRunningBuild build2 = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.USE_SHALLOW_CLONE_FROM_MIRROR_TO_CHECKOUT_DIR, "true", PluginConfigImpl.USE_MIRRORS, "true"));
    myVcsSupport.updateSources(createRoot(remote, "refs/heads/main"), new CheckoutRules(""), "fd1eb9776b5fad5cc433586f7933811c6853917d", myCheckoutDir, build2, false);
    assertTrue(shallowMarker.exists());
    assertFalse(testFile.exists());
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 22 with CheckoutRules

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

the class AgentVcsSupportTest method testSubmodulesShallowClone.

@TestFor(issues = "TW-70025")
public void testSubmodulesShallowClone() throws Exception {
    final AgentRunningBuild build = createRunningBuild(Collections.singletonMap(PluginConfigImpl.USE_SHALLOW_CLONE_INTERNAL, "true"));
    myRoot.addProperty(Constants.BRANCH_NAME, "patch-tests");
    myRoot.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.SUBMODULE_ADDED_VERSION, myCheckoutDir, build, false);
    assertTrue(new File(myCheckoutDir, "submodule" + File.separator + "file.txt").exists());
    assertTrue(new File(myCheckoutDir, ".git/modules/submodule/shallow").isFile());
}
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 23 with CheckoutRules

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

the class AgentVcsSupportTest method repo_recreated_when_shallow_fetch_disabled.

@Test
public void repo_recreated_when_shallow_fetch_disabled() throws Exception {
    final File remote = dataFile("repo_for_shallow_fetch.git");
    final File shallowMarker = new File(myCheckoutDir, ".git/shallow");
    final AgentRunningBuild build = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.USE_SHALLOW_CLONE_INTERNAL, "true"));
    myVcsSupport.updateSources(createRoot(remote, "refs/heads/main"), new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, build, false);
    assertTrue(shallowMarker.isFile());
    myVcsSupport.updateSources(createRoot(remote, "refs/heads/main"), new CheckoutRules(""), "fd1eb9776b5fad5cc433586f7933811c6853917d", myCheckoutDir, createRunningBuild(true), false);
    assertFalse(shallowMarker.exists());
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) Test(org.testng.annotations.Test)

Example 24 with CheckoutRules

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

the class AgentVcsSupportTest method testRecoverIndexLock.

/**
 * Test work normally if .git/index.lock file exists
 */
public void testRecoverIndexLock() throws Exception {
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, myBuild, false);
    // emulate incorrect git termination (in this it could leave index.lock file)
    FileUtil.copy(new File(myCheckoutDir, ".git" + File.separator + "index"), new File(myCheckoutDir, ".git" + File.separator + "index.lock"));
    myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.CUD1_VERSION, myCheckoutDir, myBuild, false);
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File)

Example 25 with CheckoutRules

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

the class AgentSideSparseCheckoutTest method update_files_after_checkout_rules_change.

public void update_files_after_checkout_rules_change() throws Exception {
    String version = "465ad9f630e451b9f2b782ffb09804c6a98c4bb9";
    AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").withAgentConfiguration(myAgentConfiguration).build();
    CheckoutRules rules = new CheckoutRules("+:dir");
    myVcsSupport.updateSources(myRoot, rules, version, myCheckoutDir, build, false);
    then(myCheckoutDir.list()).contains("dir").doesNotContain("readme.txt");
    rules = new CheckoutRules("-:dir");
    myVcsSupport.updateSources(myRoot, rules, version, myCheckoutDir, build, false);
    then(myCheckoutDir.list()).doesNotContain("dir").contains("readme.txt");
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules)

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