use of jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl in project teamcity-git by JetBrains.
the class FetchCommandImplTest method negative_refspec_for_tags.
@Test
public void negative_refspec_for_tags() throws Exception {
final String gitPath = getGitPath();
final GitVersion version = new AgentGitFacadeImpl(gitPath).version().call();
if (!GitVersion.negativeRefSpecSupported(version))
throw new SkipException("Git version is too old to run this test");
final File remote = GitTestUtil.dataFile("fetch_multiple_refspecs");
new File(remote, "refs" + File.separator + "heads").mkdirs();
final File work = createTempDir();
runCommand(false, gitPath, work, "init", "--bare");
final StringBuilder log = new StringBuilder();
final StubContext context = new StubContext("git", version);
context.setLogger(createLogger(log));
final GitCommandLine cmd = new GitCommandLine(context, getFakeGen());
cmd.setExePath(gitPath);
cmd.setWorkingDirectory(work);
final FetchCommandImpl fetch = new FetchCommandImpl(cmd);
fetch.setRemote(remote.getAbsolutePath());
fetch.setAuthSettings(getEmptyAuthSettings());
fetch.setRefspec("+refs/*:refs/*");
fetch.setRefspec("^refs/tags/*");
fetch.setFetchTags(false);
fetch.call();
// master + 6000 branches
assertEquals(6001, FileUtil.listFiles(new File(work, "refs/heads"), (d, n) -> true).length);
assertFalse(new File(work, "refs/tags/my_tag").exists());
final String logStr = log.toString();
assertFalse(logStr.contains("my_tag"));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl in project teamcity-git by JetBrains.
the class FetchCommandImplTest method fetch_multiple_refspecs.
@Test
public void fetch_multiple_refspecs() throws Exception {
final String gitPath = getGitPath();
final GitVersion version = new AgentGitFacadeImpl(gitPath).version().call();
if (!GitVersion.fetchSupportsStdin(version))
throw new SkipException("Git version is too old to run this test");
final File remote = GitTestUtil.dataFile("fetch_multiple_refspecs");
new File(remote, "refs" + File.separator + "heads").mkdirs();
final File work = createTempDir();
runCommand(false, gitPath, work, "init");
final GitCommandLine cmd = new GitCommandLine(new StubContext("git", version), getFakeGen());
cmd.setExePath(gitPath);
cmd.setWorkingDirectory(work);
final FetchCommandImpl fetch = new FetchCommandImpl(cmd);
fetch.setRemote(remote.getAbsolutePath());
fetch.setAuthSettings(getEmptyAuthSettings());
for (int i = 0; i < 6000; ++i) {
fetch.setRefspec("+refs/heads/branch" + i + ":refs/remotes/origin/branch" + i);
}
fetch.call();
assertEquals(6000, FileUtil.listFiles(new File(work, ".git/refs/remotes/origin"), (d, n) -> true).length);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl in project teamcity-git by JetBrains.
the class FetchCommandImplTest method should_throw_special_exception_when_stderr_mentions_broken_index.
@TestFor(issues = "TW-18853")
public void should_throw_special_exception_when_stderr_mentions_broken_index() throws VcsException {
AgentGitCommandLine failedCmd = new AgentGitCommandLine(null, getFakeGen(), new StubContext()) {
@Override
public ExecResult run(@NotNull GitCommandSettings settings) throws VcsException {
throw new VcsException("fatal: index file smaller than expected");
}
};
FetchCommand fetch = new FetchCommandImpl(failedCmd).setRefspec("+refs/heads/*:refs/remotes/origin/*").setTimeout(3600).setAuthSettings(getEmptyAuthSettings());
try {
fetch.call();
} catch (GitIndexCorruptedException e) {
// expected
} catch (VcsException e) {
fail("GitIndexCorruptedException should be thrown");
}
}
Aggregations