Hey,
I dont't find any interface or method to get the content / involved files of a merge request nor any Atlassian Plugin SDK API documentation at all.
May you help?
Community moderators have prevented the ability to post new answers.
Hi Andreas,
I may. You want to inject the PullRequestService into the contructor of your MergeCheck class, and use either streamChanges() or streamChangesets() with the PullRequest, depending on what you're looking for. This is (untested) code. The AbstractChangeCallback was only introduced in Stash 2.10. Otherwise you need to implement all the methods on ChangeCallback.
import com.atlassian.stash.content.*; import com.atlassian.stash.pull.*; import com.atlassian.stash.scm.pull.MergeRequestCheck; public class MyMergeCheck implements MergeCheck { public PullRequestService pullRequestService; public MyMergeCheck(PullRequestService pullRequestService) { this.pullRequestService = pullRequestService; } void check(MergeRequest request) { PullRequest pr = request.getPullRequest(); pullRequestService.streamChanges(pr.getToRef().getRepository().getId(), pr.getId(), new AbstractChangeCallback() { public boolean onChange(Change change) { // TODO } }); } }
Let me know how you go. If you get stuck I recommend pushing what you have to a public repository on Bitbucket/Github to make it easier to compare notes.
Good luck.
Charles
My comment disappeared after sending :/
Once again:
Thanks for providing this solution. I managed to detect wether a pom.xml would be involved in the merge or not.
Now i am trying to expect a certain number of approvals for the merge request, if there is a pom.xml change detected, but i failed using the example code:
https://bitbucket.org/Holzroller2k/stash-plugins
The number of approvers is always zero.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andreas,
I've sent you a pull request, and in particular pay attention to the last commit - you were counting "reviewers" but not the other participants who may have approved.
I hope that helps.
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.