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());
}
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());
}
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());
}
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);
}
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");
}
Aggregations