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

import com.atlassian.bitbucket.mesh.util.Version;

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

public interface GitBinaryHelper {

    /**
     * The minimum Git version required to run.
     */
    Version MINIMUM_VERSION = new Version(2, 31);
    /**
     * The new {@link #MINIMUM_VERSION} that will be applied in the next major release. Instances on older versions
     * of Git should be encouraged to upgrade.
     */
    Version NEXT_MINIMUM_VERSION = new Version(2, 31);

    /**
     * Attempts to the {@code git} binary in a set of predefined locations.
     * <p>
     * The following locations are searched, in order:
     * <ul>
     * <li>the configured location, if provided</li>
     * <li>each directory in the {@code PATH}, in order</li>
     * <li>default locations where {@code git} is installed</li>
     * </ul>
     *
     * @param configuredLocation default location for Git
     * @return the first Git executable above the minimum version
     * @throws IllegalStateException if an acceptable {@code git} binary could not be found
     */
    @Nonnull
    GitBinary find(@Nullable String configuredLocation);
}
