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

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.updateref.GitUpdateRef;
import com.atlassian.bitbucket.scm.git.command.updateref.GitUpdateRefDeleteBuilder;
import com.atlassian.bitbucket.scm.git.command.updateref.GitUpdateRefSetBuilder;

import javax.annotation.Nonnull;

/**
 * @since 1.3
 */
public class DefaultGitUpdateRef implements GitUpdateRef {

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

    public DefaultGitUpdateRef(GitScmCommandBuilder builder, I18nService i18nService, Repository repository) {
        this.builder = builder.command("update-ref");

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

    @Nonnull
    @Override
    public GitUpdateRefDeleteBuilder delete(@Nonnull String ref) {
        return new DefaultGitUpdateRefDeleteBuilder(builder, i18nService, repository, ref);
    }

    @Nonnull
    @Override
    public GitUpdateRefSetBuilder set(@Nonnull String ref, @Nonnull String newValue) {
        return new DefaultGitUpdateRefSetBuilder(builder, ref, newValue);
    }
}
