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

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

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Path;

public interface GitCloneBuilder extends GitProcessBuilderSupport<GitCloneBuilder> {

    /**
     * The optional name of a branch to checkout the cloned repository on.
     * <p>
     * NOTE: This <i>must</i> be a branch, Git clone does not accept qualified refs.
     *
     * @param value branch name
     * @return {@code this}
     */
    @Nonnull
    GitCloneBuilder branch(@Nullable String value);

    @Nonnull
    GitProcess<Void> build();

    @Nonnull
    GitCloneBuilder checkout(boolean value);

    /**
     * Sets the directory where the clone should be <i>created</i>.
     *
     * @param value the path to the directory where the clone should be created
     * @return {@code this}
     */
    @Nonnull
    GitCloneBuilder directory(@Nonnull Path value);

    /**
     * Sets the path to the origin repository that should be cloned.
     *
     * @param value the path to the origin repository
     * @return {@code this}
     */
    @Nonnull
    GitCloneBuilder origin(@Nonnull Path value);

    /**
     * Sets the origin repository that should be cloned.
     *
     * @param value the origin repository
     * @return {@code this}
     */
    @Nonnull
    GitCloneBuilder origin(@Nonnull Repository value);

    @Nonnull
    GitCloneBuilder origin(@Nonnull String origin);

    @Nonnull
    GitCloneBuilder quiet(boolean value);

    @Nonnull
    GitCloneBuilder shared(boolean value);

    /**
     * Sets the {@code --template} path to be used when creating the clone's repository on disk. The Git
     * distribution includes its own template, which can be overridden by using this flag.
     *
     * @param value the {@code --template} path, or {@code null} to clear the flag
     * @return {@code this}
     */
    @Nonnull
    GitCloneBuilder template(@Nullable Path value);
}
