use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class RetryTest method retryable.
@NotNull
private Retry.Retryable<Void> retryable(@NotNull final StringBuilder result, int failAttempts) {
final Ref<Integer> attemptNum = new Ref(1);
return new Retry.Retryable<Void>() {
@Override
public boolean requiresRetry(@NotNull final Exception e, int attempt, int maxAttempts) {
return attempt < maxAttempts;
}
@Nullable
@Override
public Void call() throws VcsException {
int num = attemptNum.get();
try {
if (num <= failAttempts)
throw new VcsException("the exception");
return null;
} finally {
attemptNum.set(num + 1);
}
}
@NotNull
@Override
public Logger getLogger() {
return new DefaultLogger() {
@Override
public void debug(final String message) {
throw new UnsupportedOperationException();
}
@Override
public void debug(final Throwable t) {
throw new UnsupportedOperationException();
}
@Override
public void debug(final String message, final Throwable t) {
append("DEBUG", message, t);
}
private void append(final String category, final String message, final Throwable t) {
result.append(category).append(" ").append(message);
if (t != null) {
result.append(": ").append(t.getMessage());
}
result.append("\n");
}
@Override
public void error(final String message, final Throwable t, final String... details) {
throw new UnsupportedOperationException();
}
@Override
public void info(final String message) {
append("INFO", message, null);
}
@Override
public void info(final String message, final Throwable t) {
append("INFO", message, t);
}
@Override
public void warn(final String message, final Throwable t) {
append("WARN", message, t);
}
@Override
public boolean isDebugEnabled() {
return true;
}
};
}
};
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class GitLabelingSupportTest method fail_labeling_when_heuristics_fails.
public void fail_labeling_when_heuristics_fails() throws Exception {
myConfig.setUsePackHeuristic(true);
myConfig.setFailLabelingWhenPackHeuristicsFail(true);
GitVcsSupport git = buildGit();
File remoteRepoDir = getRemoteRepositoryDir("repo_for_fetch.2");
VcsRoot root = vcsRoot().withFetchUrl(remoteRepoDir).build();
makeCloneOnServer(git, root);
// erase commit in the remote repository
FileUtil.delete(remoteRepoDir);
remoteRepoDir.mkdirs();
FileUtil.copyDir(getRemoteRepositoryDir("repo_for_fetch.1"), remoteRepoDir);
try {
// label erased commit
String erasedCommit = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
git.getLabelingSupport().label("label", erasedCommit, root, CheckoutRules.DEFAULT);
fail("Should fail labeling since heuristics fails");
} catch (VcsException e) {
assertTrue(true);
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class RepositoryManagerTest method should_not_keep_repo_opened_in_case_of_error.
public void should_not_keep_repo_opened_in_case_of_error() throws Exception {
File customDir = myTempFiles.createTempDir();
FileUtil.delete(customDir);
RepositoryManager repositoryManager = getRepositoryManager();
Repository r1 = repositoryManager.openRepository(customDir, new URIish("git://some.org/repo.git"));
try {
repositoryManager.openRepository(customDir, new URIish("git://some.org/other-repo.git"));
fail("Expect error, dir is used for another url");
} catch (VcsException e) {
assertTrue(true);
}
repositoryManager.closeRepository(r1);
Repository r2 = repositoryManager.openRepository(customDir, new URIish("git://some.org/repo.git"));
assertNotSame(r1, r2);
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class RepositoryManagerTest method should_throw_exception_when_repository_configured_for_different_url__custom_dir_case.
public void should_throw_exception_when_repository_configured_for_different_url__custom_dir_case() throws Exception {
RepositoryManager repositoryManager = getRepositoryManager();
File customDir = myTempFiles.createTempDir();
repositoryManager.openRepository(customDir, new URIish("git://some.org/repo.git"));
try {
repositoryManager.openRepository(customDir, new URIish("git://some.org/other-repo.git"));
fail("Expect error, dir is used for another url");
} catch (VcsException e) {
assertTrue(true);
}
}
use of jetbrains.buildServer.vcs.VcsException in project teamcity-git by JetBrains.
the class ShowRefCommandImpl method call.
@NotNull
public ShowRefResult call() {
GitCommandLine cmd = getCmd();
cmd.addParameter("show-ref");
if (myPattern != null)
cmd.addParameters(myPattern);
if (myShowTags)
cmd.addParameter("--tags");
try {
ExecResult result = CommandUtil.runCommand(cmd);
return new ShowRefResult(parseValidRefs(result.getStdout()), parseInvalidRefs(result.getStderr()), result.getExitCode());
} catch (VcsException e) {
getCmd().getContext().getLogger().warning("show-ref command failed, empty result will be returned: " + e.getMessage());
return new ShowRefResult();
}
}
Aggregations