use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method testSubmodulesCheckoutWithCustomConfigPerLine.
@Test(dataProvider = "custom_config_per_line")
public void testSubmodulesCheckoutWithCustomConfigPerLine(@NotNull String line) throws Throwable {
final AgentRunningBuild build = createRunningBuild(new HashMap<String, String>() {
{
put(PluginConfigImpl.CUSTOM_GIT_CONFIG, line);
}
});
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 shallow_fetch_with_older_revision.
@Test
public void shallow_fetch_with_older_revision() 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 && "+a1d6299597f8d6f6d8316577c46cc8fffd657d5e:refs/remotes/origin/main".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/heads/main"), new CheckoutRules(""), "a1d6299597f8d6f6d8316577c46cc8fffd657d5e", myCheckoutDir, build, false);
assertEquals(1, loggingFactory.getNumberOfCalls(FetchCommand.class));
final Repository checkout = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
assertEquals("main", checkout.getBranch());
final Ref main = checkout.getRefDatabase().findRef("main");
assertNotNull(main);
assertEquals("a1d6299597f8d6f6d8316577c46cc8fffd657d5e", main.getObjectId().getName());
assertNotNull(checkout.getRefDatabase().findRef("refs/remotes/origin/main"));
assertNull(checkout.getRefDatabase().findRef("refs/tags/tag1"));
assertNotNull(checkout.getRefDatabase().findRef("refs/tags/tag2"));
assertFalse(checkout.getObjectDatabase().has(ObjectId.fromString("fd1eb9776b5fad5cc433586f7933811c6853917d")));
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method testDumpConfig.
@Test
public void testDumpConfig() throws Exception {
final File remote = dataFile("repo_for_shallow_fetch.git");
final StringBuilder log = new StringBuilder();
final AgentRunningBuild build = createRunningBuild(CollectionsUtil.asMap(PluginConfigImpl.TEAMCITY_GIT_SSH_DEBUG, "true"), new NullBuildProgressLogger() {
@Override
public void message(String message) {
log.append(message);
}
});
myVcsSupport.updateSources(createRoot(remote, "refs/heads/main"), new CheckoutRules(""), "64195c330d99c467a142f682bc23d4de3a68551d", myCheckoutDir, build, false);
final String result = log.toString();
if (SystemInfo.isWindows) {
assertTrue(result, result.contains("git config --list") || result.contains("git.exe config --list") || result.contains("git.exe\" config --list"));
} else {
BaseTestCase.assertContains(result, "git config --list");
}
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method do_not_create_branch_when_checkout_tag.
public void do_not_create_branch_when_checkout_tag() throws Exception {
myRoot.addProperty(Constants.BRANCH_NAME, "refs/tags/v1.0");
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, myBuild, false);
Repository r = new RepositoryBuilder().setWorkTree(myCheckoutDir).build();
Map<String, Ref> refs = r.getRefDatabase().getRefs("refs/");
assertTrue(refs.containsKey("tags/v1.0"));
// it is reachable from refs/tags/v1.0
assertTrue(refs.containsKey("tags/v0.7"));
// also reachable
assertTrue(refs.containsKey("tags/v0.5"));
assertEquals(3, refs.size());
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AutoCheckoutTest method exclude_rules_are_used_without_sparse_checkout.
public void exclude_rules_are_used_without_sparse_checkout() throws IOException, VcsException {
myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_WITH_SPARSE_CHECKOUT);
VcsRoot vcsRoot = vcsRootWithAgentGitPath();
AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "false").addRootEntry(vcsRoot, "-:dir/q.txt").build();
AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules("-:dir/q.txt"), build);
then(canCheckout.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES);
then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot perform sparse checkout using git " + GIT_WITH_SPARSE_CHECKOUT);
}
Aggregations