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

Is it possible to prompt the user during the creation of a Pull Request?

Nathan Swartzentruber May 12, 2016

Our current workflow involves using Pull Requests for Code Reviews of commits that are going in to our main line.  The expectation is that the developer has compiled and tested the code locally before creating a Pull Request.  I would like to make this expectation explicit by adding a small checkbox to the Pull Request creation page, asking the user to confirm that they have completed testing.  Is this possible with a plugin or some other way?

3 answers

1 accepted

1 vote
Answer accepted
Adam
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 12, 2016

You can plug into that page with a <form-fragment> plugin. This kind of plugin is something we thought we could improve on, so we never actually documented it, but it's there and I don't really see us getting rid of it anytime soon. Given the location isn't documented though, I can't promise we wouldn't remove that plugin location in a minor release.

The location you'd hook into is "bitbucket.page.createPullRequest", and you can trace back the <form-fragment> element in https://bitbucket.org/atlassian/stash-auto-unapprove-plugin/src/26996bfcd6d1acc055487241cbfa4fc85503670d/src/main/resources/atlassian-plugin.xml?at=master&fileviewer=file-view-default to see an example of how FormFragments can be used (note the context available will be different for the createPullRequest location than what the auto-unapprove plugin is using). essentially you are pretending that you are adding fields to the form to be submitted along with the form and handled by your plugin. But actually, you could just render whatever notice you want, and ignore any input validation / handling.

There's no more straightforward plugin point on that page, unfortunately.

Cheers,

Adam

1 vote
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2016

I don't know any add-on that will do that.

I, however found that it's more effective to educate your users on what needs to be done beforehand.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 19, 2016

I agree with Gabrielle... checkboxes that you must check, just become an, err, box-checking exercise... they become part of muscle memory so soon have no value at all.

Another way of accomplishing something similar is auto-adding a task to the PR - https://scriptrunner.adaptavist.com/latest/bitbucket/StashEventHandlers.html#_add_tasks_to_new_pull_requests . Then you have a merge check that prevents merge if there are uncompleted tasks.

But that's interesting about form fragments... sounds useful.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events