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

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

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

/**
 * A builder for {@code git receive-pack} commands. {@code git receive-pack} takes minimal command line
 * parameters (essentially just a repository directory), so this builder is also minimal.
 */
public interface GitReceivePackBuilder extends GitProcessBuilderSupport<GitReceivePackBuilder> {

    /**
     * Instructs {@code receive-pack} to advertise refs and then terminate, rather than waiting for a request. This
     * allows {@code receive-pack} to be used to implement HTTP handling, where refs are advertised in one request
     * and then a pack is uploaded in a second request (and sometimes more).
     *
     * @param value {@code true} to only advertise refs; otherwise {@code false} to also receive a pack
     * @return {@code this}
     */
    @Nonnull
    GitReceivePackBuilder advertiseRefs(boolean value);

    @Nonnull
    GitReceivePackBuilder directory(@Nonnull Path value);

    /**
     * Limits {@code receive-pack} to a single cycle reading from {@code stdin} and writing to {@code stdout}. This
     * allows {@code receive-pack} to be used to implement HTTP handling instead of {@code http-backend}. The default
     * allows multiple cycles, which is useful for implementing SSH handling.
     *
     * @param value {@code true} to apply a single cycle; otherwise, {@code false} to allow multiple cycles
     * @return {@code this}
     */
    @Nonnull
    GitReceivePackBuilder statelessRpc(boolean value);
}
