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

import com.atlassian.bitbucket.mesh.repository.Repository;

import javax.annotation.Nonnull;

/**
 * Describes a service for configuring transcoding in a {@link Repository repository}.
 *
 * @see Transcoder
 */
public interface TranscodeService {

    /**
     * Retrieves a flag indicating whether transcoding is enabled for the specified repository.
     *
     * @param repository the repository check transcoding for
     * @return {@code true} if {@code git blame} and {@code git diff} have been configured to use a
     *         {@code textconv} script to transcode files; otherwise, {@code false}
     */
    boolean isEnabled(@Nonnull Repository repository);

    /**
     * Specifies whether {@code git blame} and {@code git diff} should use a {@code textconv} script to
     * transcode files in the specified repository. Transcoding allows non-UTF-8 diffs to be displayed
     * correctly in any case where the source view is able to display the file, but imposes a performance
     * penalty due to that extra processing.
     *
     * @param repository the repository to configure transcoding for
     * @param enabled    {@code true} to transcode files; otherwise, {@code false}
     */
    void setEnabled(@Nonnull Repository repository, boolean enabled);
}
