Forums

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

Preventing changes to specific file/line/variable

Deleted user October 31, 2021

Hey,

I need to prevent merging to a specific branch any pull requests that include a change to a specific Python variable.

Is it possible to do this? Maybe just for a specific line or a specific file? Or maybe instead of preventing the merge, add an alert? 

Thanks!

2 answers

0 votes
Aron Gombas _Midori_
Community Champion
November 1, 2021

It may be a bit heavyweight for your use case, but you could:

  1. Create a commit policy with the Changed paths (files) must match a pattern condition. It will reject changes made on the configured set of files. (It will not check the content of the file though.)
  2. Install it as a local pre-commit hook to every developer's local clone.

That way, developers won't be able to create a commit to that file, so this approach catches the problem early on.

(Disclaimer: this solution requires a paid Jira app that I'm working on.)

condition-file-pattern.png

0 votes
Ulrich Kuhnhardt _IzymesCo_
Atlassian Partner
October 31, 2021

The best option to stop a PR merge under a certain condition would be to create a configurable merge-check. The merge-check would scan the change set in the source branch and detect any condition you configure.

Unfortunately this is not possible with bitbucket cloud branch permissions - however there is an existing feature request https://jira.atlassian.com/browse/BCLOUD-19885 that would allow you to create such a merge-check. Please vote and add yourself as a watcher.

Best, Ulrich

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events