Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I disable re-writing a branch history if and only if a PR is open against a branch?

Bassam Khouri July 19, 2018

my company used BitBucket Cloud.

 

I know that I can configure branch permissions to disable re-writing history based on a regex-list pattern.

 

Screen Shot 2018-07-19 at 3.00.21 PM.png

However, I want to allow the developers to rewrite branch history to their hearts content, and prevent it if, and only if, that branch is the source branch of a Pull Request.  We have Merge check configure to not merge if there are open bitbucket tasks against the PR.

Here's the workflow:

User #1.

  • Create a branch on the remote server.
  • Commit, commit, commit and push
  • Commit, push
  • Perform interactive rebase and squash all commit into a single one.  git push
  • Create a PR and add user #2

User #2:

  • Open PR.  
  • Adds a few BitBucket tasks and approves

User #1:

  • Addresses the comments.  Does it git commit
  • Before pushing an update, does a git rebase and update the branch history  <<< I want this to fail because a PR is open againt the branch
  • Pushes the changes

User #2:

  • Received an notification PR has been updated. 
  • Opens the PR and goes to the "Activity" tab.
  • Search for the "User #1 approved" message and select the "See what's changed link"
    Screen Shot 2018-07-19 at 3.09.54 PM.png
  • User freaks out because the diff shows code changes unrelated to the "fix"

When this happens, the commit that was approved no longer appears in the PR "commits" view.

 

Is it possible to disable rewriting the branch history if, and only if, a branch has an open PR against it?

1 answer

0 votes
Spenser Gilliland
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 20, 2020

I want this functionality as well.  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events