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

import com.atlassian.bitbucket.mesh.git.builder.GitProcess;
import com.atlassian.bitbucket.mesh.git.builder.GitProcessBuilderSupport;

import javax.annotation.Nonnull;

/**
 * A base class for constructing builders around {@code git merge}, supplying properties which are common to all
 * usages of the command.
 */
public interface GitMergeBuilderSupport<B extends GitMergeBuilderSupport<B>> extends GitProcessBuilderSupport<B> {

    /**
     * Specifies whether merges between commits with no shared history (e.g. distinct root commits) is allowed.
     * Starting in Git 2.9, {@code git merge} by default will not allow merging unrelated commits; prior to 2.9
     * such merges were allowed by default.
     *
     * @param value {@code true} to allow merging unrelated commits; otherwise, {@code false} to reject such merges
     * @return {@code this}
     */
    B allowUnrelatedHistories(boolean value);

    /**
     * Starts a process which will run the configured merge, <i>discarding any output</i>. If the
     * output contains error messages, <i>they will be ignored</i>.
     *
     * @return a {@link GitProcess process} to execute the configured merge
     */
    @Nonnull
    GitProcess<Void> build();

    /**
     * Specifies the commit to be merged into the {@code HEAD} revision of the repository against which the command
     * is executed.
     *
     * @param value the commit to merge, which may be a short or qualified branch or tag name, or a short or full
     *              commit hash
     * @return {@code this}
     */
    @Nonnull
    B commit(String value);

    /**
     * Sets the fast-forward mode to use when executing {@code git merge}. The modes available are documented on the
     * enumeration.
     *
     * @param value the fast-forward mode to apply when performing the merge
     * @return {@code this}
     */
    @Nonnull
    B ff(GitMergeFastForward value);

    /**
     * Sets a flag which controls the output produced by {@code git merge}.
     *
     * @param value {@code true} to reduce or eliminate output; otherwise, {@code false} (the default) to produce
     *              normal output
     * @return {@code this}
     */
    @Nonnull
    B quiet(boolean value);

    /**
     * Controls whether {@code git merge} will try to run hooks like {@code commit-msg} and {@code pre-merge-commit}.
     *
     * @param value the verification mode to use
     * @return {@code this}
     */
    @Nonnull
    B verify(@Nonnull GitMergeVerify value);
}
