Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Merge button not enabled after merge check conditions are met

Denis Stafichuk June 9, 2015

I'm developing stash plugin to check if all reviews approved a pull request before it can be merged. I've used https://bitbucket.org/atlassian/stash-example-merge-check-config as an example. If one or more reviewers did not approve pull request I call veto method on object of class com.atlassian.stash.scm.pull.MergeRequest.

The problem is merge button do not becoming enabled after last reviewer clicks approve button like it do when conditions set in "Pull requests" section in repository settings are met. It becoming enabled only after refreshing the page. I'm facing this issue with https://bitbucket.org/atlassian/stash-example-merge-check-config as well. I also tried to use merge-check plugin module instead of repository hook, but to no avail. I'm using stash version 3.7.2.

Is this bug in stash or am I doing something wrong?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 10, 2015

Currently Stash's frontend only checks back with the server for mergeability when an event occurs that it knows can affect mergeability - tasks completed or approvals - and only if the relevant merge check is enabled.

Since Stash doesn't know about your plugin, and presumably you have the built-in approvers merge check disabled, it won't fetch an update from the server when someone approves.

We use an internal module to do the check. Unfortunately since it's not API, it shouldn't be considered stable and might break when you update Stash. However if you want to use it anyway, require the 'feature/pull-request/can-merge' module from AMD and call it when someone approves or unapproves.

require([
    'feature/pull-request/can-merge'
    'stash/api/util/events'
], function(canMerge, events) {
    events.on('stash.widget.approve-button.added', canMerge.bind(null, null));
    events.on('stash.widget.approve-button.removed', canMerge.bind(null, null));
});

The page will update to reflect the mergeability.

TAGS
AUG Leaders

Atlassian Community Events