How can we prevent a pull request from incorporating a subsequent end-of-day commit to the same branch?

My team is using pull requests, and we also push our latest changes at the end of the day, even if the latest is a work-in-progress.  This has the unfortunate side-effect of sometimes updating a previous pull request with broken code.  I can imagine a few possible solutions:

  1. Open the pull request on a commit instead of on a branch (I can't seem to find an option to open a pull request on a commit in the Bitbucket web UI; does it only support pull requests on branches?)
  2. Work in one branch, but create or maintain a separate branch for the pull request
  3. Commit in-progress work locally at the end of the day but don't push (we prefer to push every day in case someone needs to resume or incorporate someone else's work)

Are there any other options I'm missing, and what solution worked for you to resolve this issue?

 

2 answers

This widget could not be displayed.

I don't know what your branching strategy is, but typically if you're working on a feature branch, you should only issue a pull request for that branch when the feature is complete.  Then you should start working on your next feature on a new feature branch.  The only reason, in my opinion, that there should be additional commits on the same branch that the pull request was issued for is if the pull request review process has uncovered changes that needed to be made.

That said, in Settings->Pull Requests there is a checkbox to "unapprove all reviewers when the source branch of a pull request changes".  That box along with requiring a minimum number of approvers (on the same screen) should help prevent this problem, I think.

That will prevent the incorrect merge - it won't allow you to do the one you wanted to do, though.  Ultimately, a pull request is merging a branch, not a specific commit.  You could create a branch just for the pull request that you never advance, but I still think feature branching is the best way to go.

This widget could not be displayed.

Need a few clarifications!  What branch is everyone pushing their "end-of-day" work into?  And are the pull-requests FROM 'master' or TO 'master'?   (In other words, what are the source and target branches of the pull-requests?)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,596 views 9 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you