use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AutoCheckoutTest method should_respect_root_settings_when_checking_multi_root_constraints2.
@TestFor(issues = "TW-49786")
public void should_respect_root_settings_when_checking_multi_root_constraints2() throws Exception {
VcsRoot root1 = vcsRoot().withId(1).withFetchUrl("http://some.org/repo1.git").build();
VcsRoot root2 = vcsRoot().withId(2).withFetchUrl("http://some.org/repo2.git").build();
AgentRunningBuild build = runningBuild().addRootEntry(root1, "+:dir1").addRootEntry(root2, "+:dir2").build();
// both roots require sparse checkout and mapped into the same directory, but the second
// root uses git version which doesn't support sparse checkout; we shouldn't take it into
// account during canCheckout() check for the first root
GitDetector detector = new GitDetector() {
@NotNull
public GitExec getGitPathAndVersion(@NotNull VcsRoot root, @NotNull BuildAgentConfiguration config, @NotNull AgentRunningBuild build) throws VcsException {
if (root.equals(root1)) {
return new GitExec("git1", GIT_WITH_SPARSE_CHECKOUT);
}
if (root.equals(root2)) {
return new GitExec("git2", GIT_WITH_SPARSE_CHECKOUT.previousVersion());
}
throw new VcsException("Unexpected VCS root");
}
@NotNull
@Override
public GitExec getGitPathAndVersion(@NotNull AgentRunningBuild build) throws VcsException {
throw new UnsupportedOperationException();
}
};
myVcsSupport = createVcsSupport(detector);
AgentCheckoutAbility canCheckout1 = myVcsSupport.canCheckout(root1, new CheckoutRules("+:dir1"), build);
AgentCheckoutAbility canCheckout2 = myVcsSupport.canCheckout(root2, new CheckoutRules("+:dir2"), build);
then(canCheckout1.getCanNotCheckoutReason()).isNull();
then(canCheckout2.getCanNotCheckoutReason().getType()).isEqualTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES);
then(canCheckout2.getCanNotCheckoutReason().getDetails()).contains("Cannot perform sparse checkout using git " + GIT_WITH_SPARSE_CHECKOUT.previousVersion());
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AutoCheckoutTest method should_check_shared_paths_not_clashing.
public void should_check_shared_paths_not_clashing() throws Exception {
myVcsSupport = vcsSupportWithFakeGitOfVersion(GIT_CLEAN_LEARNED_EXCLUDE);
final VcsRoot vcsRoot = vcsRoot().withFetchUrl("/some/path").withAgentGitPath(getGitPath()).build();
{
final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), "some/path=>.").build();
AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, CheckoutRules.DEFAULT, build);
then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
}
{
final AgentRunningBuild build = runningBuild().sharedConfigParams(PluginConfigImpl.USE_SPARSE_CHECKOUT, "true").addRoot(vcsRoot).addRootEntry(new VcsRootImpl(2, "svn"), ".=>some/path").build();
AgentCheckoutAbility canCheckout = myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(".=>some/path"), build);
then(canCheckout.getCanNotCheckoutReason().getDetails()).contains("Cannot checkout VCS root", "into the same directory as VCS root");
}
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method not_fetch_submodules.
@TestFor(issues = "TW-63901")
@Test
public void not_fetch_submodules() throws Exception {
final File repo = new File(getTempDirectory(), "TW-63901");
FileUtil.delete(repo);
copyDir(dataFile("TW-63901-1"), repo);
final File submoduleRepo = new File(getTempDirectory(), "TW-63901-submodule");
FileUtil.delete(submoduleRepo);
copyDir(dataFile("TW-63901-submodule"), submoduleRepo);
final VcsRootImpl root = createRoot(repo, "master");
root.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.CHECKOUT.name());
final AgentRunningBuild build = createRunningBuild(new HashMap<String, String>() {
{
put(PluginConfigImpl.USE_MIRRORS, "false");
put(PluginConfigImpl.USE_MIRRORS_FOR_SUBMODULES, "false");
}
});
myVcsSupport.updateSources(root, new CheckoutRules(""), "78fcadbf51f44cf78fce816be5e3943e4bb5f95c", myCheckoutDir, build, false);
assertTrue(new File(myCheckoutDir, ".gitmodules").isFile());
assertTrue(new File(myCheckoutDir, "TW-63901-submodule/f.txt").isFile());
// patch config to fetch submodules during fetch
final StoredConfig config = new RepositoryBuilder().setWorkTree(myCheckoutDir).build().getConfig();
config.setBoolean("fetch", null, "recursesubmodules", true);
config.save();
root.addProperty(Constants.SUBMODULES_CHECKOUT, SubmodulesCheckoutPolicy.IGNORE.name());
FileUtil.delete(repo);
// new repo references submodule commit, which doesn't exist
copyDir(dataFile("TW-63901-2"), repo);
myVcsSupport.updateSources(root, new CheckoutRules(""), "565f5f32581cd1dba1305c5f5651270c33f40323", myCheckoutDir, build, false);
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method should_create_bare_repository_in_caches_dir.
public void should_create_bare_repository_in_caches_dir() throws Exception {
File mirrorsDir = myBuilder.getAgentConfiguration().getCacheDirectory("git");
assertTrue(mirrorsDir.listFiles(new FileFilter() {
public boolean accept(File f) {
return f.isDirectory();
}
}).length == 0);
myVcsSupport.updateSources(myRoot, new CheckoutRules(""), GitVcsSupportTest.VERSION_TEST_HEAD, myCheckoutDir, myBuild, false);
GitVcsRoot root = new AgentGitVcsRoot(myBuilder.getMirrorManager(), myRoot, myTookenStorage);
File bareRepositoryDir = root.getRepositoryDir();
assertTrue(bareRepositoryDir.exists());
// check some dirs that should be present in the bare repository:
File objectsDir = new File(bareRepositoryDir, "objects");
assertTrue(new File(bareRepositoryDir, "info").exists());
assertTrue(objectsDir.exists());
assertTrue(new File(bareRepositoryDir, "refs").exists());
String config = FileUtil.loadTextAndClose(new FileReader(new File(bareRepositoryDir, "config")));
assertTrue(config.contains("[remote \"origin\"]"));
String remoteUrl = "url = " + root.getRepositoryFetchURL();
assertTrue(config.contains(remoteUrl));
File packDir = new File(objectsDir, "pack");
// 2 - because there are 2 dirs there: info and pack
boolean looseObjectsExists = objectsDir.listFiles().length > 2;
// at least one pack file with its index exists
boolean packFilesExists = packDir.listFiles().length >= 2;
boolean fetchWasDone = looseObjectsExists || packFilesExists;
assertTrue(fetchWasDone);
}
use of jetbrains.buildServer.vcs.CheckoutRules in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method checkout_tag.
public void 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();
Ref tagRef = r.exactRef("refs/tags/v1.0");
assertNotNull(tagRef);
}
Aggregations