package com.atlassian.bitbucket.mesh.git.builder.rebase;

import com.atlassian.bitbucket.mesh.git.GitProcessCompletionHandler;
import com.atlassian.bitbucket.mesh.git.exception.RebaseConflictedException;
import com.atlassian.bitbucket.mesh.process.ProcessSummary;

import javax.annotation.Nonnull;

public class RebaseCompletionHandler extends GitProcessCompletionHandler {

    @Override
    protected void evaluateStderr(@Nonnull ProcessSummary summary, @Nonnull String stderr) {
        if (stderr.contains("Failed to merge in the changes.") || //Git <2.26
                stderr.contains("Resolve all conflicts")) { //Git 2.26+
            throw new RebaseConflictedException();
        }

        super.evaluateStderr(summary, stderr);
    }
}
