package com.atlassian.stash.internal.scm.git.command.blame;

import com.atlassian.bitbucket.i18n.I18nService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.scm.git.command.GitScmCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.blame.GitBlame;

import javax.annotation.Nonnull;

public class DefaultGitBlame implements GitBlame {

    private final GitScmCommandBuilder builder;
    private final I18nService i18nService;
    private final Repository repository;

    public DefaultGitBlame(GitScmCommandBuilder builder, I18nService i18nService, Repository repository) {
        this.builder = builder.command("blame");

        this.i18nService = i18nService;
        this.repository = repository;
    }

    @Nonnull
    @Override
    public DefaultGitBlameBuilder incremental() {
        return blameBuilder(BlameFormat.INCREMENTAL);
    }

    @Nonnull
    @Override
    public DefaultGitBlameBuilder porcelain() {
        return blameBuilder(BlameFormat.PORCELAIN);
    }

    private DefaultGitBlameBuilder blameBuilder(BlameFormat format) {
        return new DefaultGitBlameBuilder(builder, i18nService, repository, format);
    }
}
