Getting commits in a pull request

Nathan Button January 8, 2015

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.  

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Marcin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 8, 2015

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

TAGS
AUG Leaders

Atlassian Community Events