package com.atlassian.bitbucket.mesh.transaction;

import com.atlassian.bitbucket.mesh.execution.ExecutionContext;
import com.atlassian.bitbucket.mesh.git.ref.RefUpdate;
import com.atlassian.bitbucket.mesh.repository.Repository;

import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Describes the expected ref updates for the currently active {@code git} operation.
 *
 * @see UpdateRefsContextHolder
 */
public interface UpdateRefsContext {

    /**
     * Clears the committed marker for the passed in ref IDs.
     *
     * @param refId the sset of ref IDs
     */
    void clearCommitted(@Nonnull Collection<String> refId);

    /**
     * Removes the context from the {@link ExecutionContext} if active.
     */
    void close();

    @Nonnull
    Set<String> getCommittedRefUpdates();

    /**
     * @return map of the expected ref updates, by ref ID
     */
    @Nonnull
    Map<String, RefUpdate> getRefUpdates();

    /**
     * @return the repository for which the ref update is expected
     */
    @Nonnull
    Repository getRepository();

    /**
     * Marks the provided ref IDs as committed.
     *
     * @param refIds the set of ref IDs
     */
    void markCommitted(@Nonnull Collection<String> refIds);
}
