Expose mergeable_discussions_state and has_conflicts in Merge Request API
Problem to solve
Several teams use external "bots" to do Merge Request checking and processing; when a MR is submitted to the bot with unresolved discussions or conflicts, the bot has no way to detect that from the API and does not return a useful error when merge is attempted. Exposing mergeable_discussions_state? and cannot_be_merged? (as has_conflicts) resolves this and allows the bot to reject the MR if discussions are not resolved or there are conflicts.
This use to be visible by pulling the MR's .json widget, but access to that was closed off in the past year via tokens.
The use of an automated merging tool is becoming common here as we have hundreds of developers working in some repos and some mechanism is needed to orderly handle merges into the master branch; with it, there are race conditions getting a MR rebased and through CI before another merge is made. The bot can only work well if it has visibility into the MR state.
Include mergeable_discussions_state and cannot_be_merged in the "Show a MR" API call.
Diff on lib/api/entities.rb
689,692d708 < expose :cannot_be_merged?, as: :has_conflicts < expose :mergeable_discussions_state?, as: :mergeable_discussions_state do |merge_request| < merge_request.mergeable_discussions_state? < end
Permissions and Security
No permission changes
MR API doc will need to be updated with new field.
What does success look like, and how can we measure that?
Greater ability to manage MR processing, greater visibility to why merge is being rejected, less frustratino