use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method stop_use_any_mirror_if_agent_property_changed_to_false.
public void stop_use_any_mirror_if_agent_property_changed_to_false() throws Exception {
AgentRunningBuild build2 = createRunningBuild(false);
GitVcsRoot root = new AgentGitVcsRoot(myBuilder.getMirrorManager(), myRoot, myTookenStorage);
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, build2, false);
// add some mirror
Repository r = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
StoredConfig config = r.getConfig();
config.setString("url", "/some/path", "insteadOf", root.getRepositoryFetchURL().toString());
config.save();
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, build2, false);
config = new RepositoryBuilder().setWorkTree(myCheckoutDir).build().getConfig();
assertTrue(config.getSubsections("url").isEmpty());
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method do_not_use_mirror_if_agent_property_set_to_false.
public void do_not_use_mirror_if_agent_property_set_to_false() throws Exception {
AgentRunningBuild build2 = createRunningBuild(false);
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, build2, false);
File gitConfigFile = new File(myCheckoutDir, ".git" + File.separator + "config");
String config = FileUtil.loadTextAndClose(new FileReader(gitConfigFile));
assertFalse(config, config.contains("insteadOf"));
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method testSubmodulesCheckout.
/**
* Test checkout submodules on agent. Machine that runs this test should have git installed.
*/
private void testSubmodulesCheckout(boolean useMirrorsForSubmodules, boolean useAlternates) throws Exception {
final AgentRunningBuild build = createRunningBuild(new HashMap<String, String>() {
{
put(PluginConfigImpl.USE_MIRRORS, useMirrorsForSubmodules ? "true" : null);
put(PluginConfigImpl.USE_MIRRORS_FOR_SUBMODULES, useMirrorsForSubmodules ? "true" : "false");
put(PluginConfigImpl.USE_ALTERNATES, useAlternates ? "true" : "false");
}
});
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());
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method testSubmmoduleCommitReferencedByTag_alternates.
@TestFor(issues = "TW-65043")
public void testSubmmoduleCommitReferencedByTag_alternates() throws Exception {
final AgentRunningBuild build = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.USE_ALTERNATES, "true"));
myRoot.addProperty(Constants.BRANCH_NAME, "TW-65043");
myRoot.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), "4be4cc77ac427ecabf6ca53a76e33f6e186db6f2", myCheckoutDir, build, false);
final File file = new File(myCheckoutDir, "submodule" + File.separator + "file.txt");
assertTrue(file.exists());
assertEquals("TW-65043", FileUtil.readText(file, "UTF-8").trim());
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method shallow_fetch_tag.
@Test
public void shallow_fetch_tag() throws Exception {
final File remote = dataFile("repo_for_shallow_fetch.git");
final LoggingGitMetaFactory loggingFactory = new LoggingGitMetaFactory();
loggingFactory.addCallback(FetchCommand.class.getName() + ".setRefspec", new GitCommandProxyCallback() {
@Override
public Optional<Object> call(final Method method, final Object[] args) throws VcsException {
if (args.length == 1 && "+refs/tags/tag1:refs/tags/tag1".equals(args[0]))
return null;
fail("Unexpected fetch refspec " + Arrays.toString(args));
return null;
}
});
loggingFactory.addCallback(FetchCommand.class.getName() + ".setDepth", new GitCommandProxyCallback() {
@Override
public Optional<Object> call(final Method method, final Object[] args) throws VcsException {
if (args.length == 1 && Integer.valueOf(1).equals(args[0]))
return null;
fail("Unexpected fetch depth " + Arrays.toString(args));
return null;
}
});
myVcsSupport = myBuilder.setGitMetaFactory(loggingFactory).setFS(new MockFS()).build();
final AgentRunningBuild build = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.USE_SHALLOW_CLONE_INTERNAL, "true"));
myVcsSupport.updateSources(createRoot(remote, "refs/tags/tag1"), new CheckoutRules(""), "fd1eb9776b5fad5cc433586f7933811c6853917d", myCheckoutDir, build, false);
assertEquals(1, loggingFactory.getNumberOfCalls(FetchCommand.class));
final Repository checkout = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
final Ref main = checkout.getRefDatabase().findRef("refs/tags/tag1");
assertNotNull(main);
assertEquals("fd1eb9776b5fad5cc433586f7933811c6853917d", main.getObjectId().getName());
assertNull(checkout.getRefDatabase().findRef("refs/tags/tag2"));
assertFalse(checkout.getObjectDatabase().has(ObjectId.fromString("a1d6299597f8d6f6d8316577c46cc8fffd657d5e")));
}
Aggregations