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

Is there a way to always enforce Pull Requests instead of allowing pushing directly to a repository?

Christoffer Pettersson November 19, 2013

Hey.

I am new to Atlassian Stash, but I have been playing around for a day now.

Looking at the "Repository Pemissions" page:

https://confluence.atlassian.com/display/STASH028/Using+repository+permissions

I can read that a user with the WRITE permission can create a Pull Request, approve and merge it, but also Push directly to the repository.

It seems like users with the WRITE permission can bypass all kinds of code review by pushing directly to the branch, hence by ignoring to create Pull Requests.

Is there a way that enforce that all commits to master has to be done via Pull Requests?

5 answers

1 accepted

0 votes
Answer accepted
Christoffer Pettersson November 19, 2013

Oh I see that this question has already been asked here:

https://answers.atlassian.com/questions/152360/branch-permissions-only-allow-commits-via-pull-request

And it is not possible.

7 votes
pmckeenACN March 15, 2017

Branch permissions now support separate permissions for writing directly to the branch vs merging via pull request.

engineeringman February 13, 2019

This needs to be heard!  I wish there was a way to resurrect this.

Like kingdonb likes this
kingdonb February 13, 2019

Per my reply below the fold, you can also "Prevent a merge with unresolved merge checks" which is big, too.

Like engineeringman likes this
2 votes
Richard Cross March 13, 2015

UPDATE:  This functionality is now a part of Bitbucket.  Under Repository Settings > Branch Permissions,  you can select any branch (e.g. “master”) and then add the restriction “Prevent changes without a pull request”.

Previous Answer:

There are two 3rd party plugins that provide this missing functionality - "Pull Request Please" and "Workzone".

A JIRA was raised way back in 2012, but I don't think there's any chance of it being actioned.

 

1 vote
kingdonb January 2, 2018

This story appears to be substantially improved now: https://confluence.atlassian.com/bitbucket/suggest-or-require-checks-before-a-merge-856691474.html

You can separately grant permissions to individual branches including both "Write" and "Merge via Pull Request"

You can also "Prevent a merge with unresolved merge checks"

Phillip McKeen February 13, 2019

Worth noting: preventing merge based on merge checks is (or was when I last checked) a premium feature.

Like # people like this
1 vote
Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 19, 2013

You could setup Branch Permissions so that only certain people can write to a branch.

Christoffer Pettersson November 19, 2013

True, but I want everyone to be able to approve and merge, and I want everyone to create Pull Requests, but no one to push directly to the branch.

The problem, I think, is that the WRITE permission allows both approve+merge AND pushing directly. So if we want to enforce code review, we need to enforce Pull Requests. But with the WRITE permission you can bypass creating Pull Requests and push your commit directly to the branch, bypassing the whole code review process.

So my question still stands; Is there a way that enforce that all commits to master has to be done via Pull Requests?

Like Aaron Liu likes this
Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 19, 2013

Sorry, I missed where you want to people to still be able to approve and merge.

You could setup a pre-receive hook by creating a plugin that prevents pushes to certain branches. See this answer for more details.

There is an open JIRA issue to do what you need without having to write a plugin, see STASH-2910.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events