Search in sources :

Example 1 with GitIndexCorruptedException

use of jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitIndexCorruptedException in project teamcity-git by JetBrains.

the class CommandUtil method isRecoverable.

public static boolean isRecoverable(@NotNull Exception e, AuthSettings authSettings, int attempt, int maxAttempts) {
    boolean attemptsLeft = attempt < maxAttempts;
    if (e instanceof ProcessTimeoutException || e instanceof GitExecTimeout)
        return attemptsLeft;
    if (!(e instanceof VcsException))
        return false;
    final VcsException ve = (VcsException) e;
    if (isTimeoutError(ve) || isConnectionRefused(ve) || isConnectionReset(ve))
        return attemptsLeft;
    if (isCanceledError(ve))
        return false;
    if (e instanceof GitIndexCorruptedException)
        return false;
    if (authSettings.doesTokenNeedRefresh() && attempt == 1)
        return true;
    return attemptsLeft && !isRemoteAccessError(ve);
}
Also used : GitExecTimeout(jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitExecTimeout) GitIndexCorruptedException(jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitIndexCorruptedException) VcsException(jetbrains.buildServer.vcs.VcsException) ProcessTimeoutException(jetbrains.buildServer.ProcessTimeoutException)

Example 2 with GitIndexCorruptedException

use of jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitIndexCorruptedException 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");
    }
}
Also used : GitCommandSettings(jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandSettings) FetchCommandImpl(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl) GitIndexCorruptedException(jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitIndexCorruptedException) FetchCommand(jetbrains.buildServer.buildTriggers.vcs.git.command.FetchCommand) StubContext(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.StubContext) VcsException(jetbrains.buildServer.vcs.VcsException) AgentGitCommandLine(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitCommandLine) NotNull(org.jetbrains.annotations.NotNull) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

GitIndexCorruptedException (jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitIndexCorruptedException)2 VcsException (jetbrains.buildServer.vcs.VcsException)2 ProcessTimeoutException (jetbrains.buildServer.ProcessTimeoutException)1 AgentGitCommandLine (jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentGitCommandLine)1 FetchCommand (jetbrains.buildServer.buildTriggers.vcs.git.command.FetchCommand)1 GitCommandSettings (jetbrains.buildServer.buildTriggers.vcs.git.command.GitCommandSettings)1 GitExecTimeout (jetbrains.buildServer.buildTriggers.vcs.git.command.errors.GitExecTimeout)1 FetchCommandImpl (jetbrains.buildServer.buildTriggers.vcs.git.command.impl.FetchCommandImpl)1 StubContext (jetbrains.buildServer.buildTriggers.vcs.git.command.impl.StubContext)1 TestFor (jetbrains.buildServer.util.TestFor)1 NotNull (org.jetbrains.annotations.NotNull)1