I need to be able to get the individual commits involved with a pull request. Our company policy is that if you wrote one of the commits involved in a pull request you are not allowed to merge that request.
Currently the plugin only checks the Author of the pull request.
public void check(@Nonnull RepositoryMergeRequestCheckContext context){ StashUser currentUser = authenticationContext.getCurrentUser(); MergeRequest mergeRequest = context.getMergeRequest(); if(currentUser.equals(mergeRequest.getPullRequest().getAuthor().getUser()) { mergeReuest.veto(/*Reasons why and such */); } }
This currently works for checking the author of the commit, but I can't figure out how to get the individual commits included in the pull request.
Community moderators have prevented the ability to post new answers.
Nathan,
There's an existing question that matches what you are after: https://answers.atlassian.com/questions/10389015
In summary though you can get all the Changeset
objects for a PullRequest
using the CommitService
:
commitService.getChangesetsBetween(ChangesetsBetweenRequest.Builder(pullRequest).build(), pageRequest);
The Changeset
will contain information about the Author of that changeset.
Regards,
Marcin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.