package com.atlassian.stash.rest.pull;

import com.atlassian.bitbucket.scm.pull.MergeRequest;
import com.atlassian.bitbucket.scm.pull.MergeRequestCheck;

import javax.annotation.Nonnull;
import java.util.Locale;

public class VetoingMergeCheck implements MergeRequestCheck {

    public static final String VETO_DETAIL = "This merge request was vetoed as requested";
    public static final String VETO_SUMMARY = "Vetoed as requested";

    @Override
    public void check(@Nonnull MergeRequest request) {
        if (request.getPullRequest().getTitle().toLowerCase(Locale.US).equals("veto")) {
            request.veto(VETO_SUMMARY, VETO_DETAIL);
        }
    }
}
