Bitbucket Server/Data Center Auto Unapprove plugin does not remove approvals even after new commits are pushed to the source branch
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Bitbucket Server/Data Center Auto Unapprove plugin does not remove approvals from Pull Request even after new commits are pushed to the Source Branch.
Environment
All
Diagnosis
- The Auto Unapprove Plugin does not remove approvals even after new commits are pushed to a pull request Source Branch.
The logs will show that both before and after diff patch ids are same after the Pull Request rescoping is completed. (Since the diff patch ids are same, it means that there was no change to the diffs between the source and the target branch even after the new commits were pushed)
2023-01-25 08:25:53,358 DEBUG [pull-request-rescoping:thread-1] c.a.s.i.p.r.PullRequestRescopeBucketProcessor MYP/repo1[1]: Rescoping completed (0 errors, 0 skipped) 2023-01-25 08:25:53,378 DEBUG [threadpool:thread-2] c.a.b.i.unapprove.GitRescopeAnalyzer Old patch ID(s): [f9591347a8c1cfcd1e87b38d17653d4ed2e91492]; new patch ID(s): [f9591347a8c1cfcd1e87b38d17653d4ed2e91492]
You can also verify if the diff patch ids are same before and after the new commit were pushed using below command on your local copy of the repository.
git diff <<target_branch>>...<<source_branch_old_commitid>> | git patch-id --stable git diff <<target_branch>>...<<source_branch_new_commitid>> | git patch-id --stable
Cause
- This is due to a feature of Auto Unapprove plugin where it will only trigger if there is an actual material change in diffs between the two branches. Actions like Clean sync-merges, amending commit messages, rebases, etc, that do not change the diff will not trigger the unapprove.
- This is also better explained with examples here : auto-unapprove issue 15. This is an additional check that was incorporated to eliminate spurious unapproves.
Solution
As mentioned in the README of the plugin this "default" behaviour can be disabled at a global level by setting "
plugin.bitbucket-pr-auto-unapprove.gitrescopeanalyzer.patchid.enabled
" to false in the Bitbucket properties file.Additionally Patch ID can be expensive to compute. By default, it will timeout after 20 seconds and reset the approvals, but this behaviour can also be configured globally by setting "
plugin.bitbucket-pr-auto-unapprove.gitrescopeanalyzer.patchid.timeout.seconds
".