package com.atlassian.bitbucket.mesh.git.auth;

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

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface GitAuthenticationHelper {

    /**
     * Configures the supplied {@link GitProcessBuilderSupport} to make authenticated requests. This will prevent the
     * Git command from prompting for a password. This is useful for making requests to remote repositories.
     *
     * @param builder adds authentication information to this builder
     * @param <B> the type of the configured {@link GitProcessBuilderSupport}
     * @param url the url to apply the credentials for
     * @param credentials credentials used for authentication
     * @return processBuilder configured with authentication credentials
     */
    @Nonnull
    <B extends GitProcessBuilderSupport<B>> B configure(@Nonnull B builder, @Nullable String url,
                                                        @Nullable Credentials credentials);
}
