Understanding pull requests in Bitbucket Server

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

This page aims to explain what happens during the lifecycle of a pull request in Bitbucket Server.

Solution

Diff view

See the Understanding Diff view in Bitbucket Server page for details.

Merge workflow

When a merge is triggered, the following two main actions are performed:

  • the merge itself
  • the removal of the source branch (if the "Delete source branch after merging" option is selected)

These operations can be found in the access log in the following format:

  • The merge request. When the merge is successful, the output code for this request is 200.
"POST /rest/api/latest/projects/<project_key>/repos/<repository_slug>/pull-requests/<pullrequest_id>/merge HTTP/1.0"
  • The branch deletion. This is triggered by the browser when the confirmation that the merge succeeded is received.  When the deletion is successful, the output code for this request is 204.
"POST /rest/pull-request-source-branch-deletion/1.0/projects/<project_key>/repos/<repository_slug>/pull-requests/<pullrequest_id>"

When the debug log level is enabled, the Git commands are logged in the atlassian-bitbucket.log file:

git clone --no-checkout --shared -b <source_branch> /var/atlassian/application-data/bitbucket/shared/data/repositories/<repository_id> /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git
 
cd /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git

git reset --quiet <target_branch_hash> --

git merge -m "Automatic merge" --no-ff --log <source_branch_hash>

Troubleshooting

In some cases, it may be needed to run some of all the commands above for testing (e.g. when the merge is slow or the merge does not produce the expected behavior).

This is possible by running them in the same order as Bitbucket Server does, please select a <temporary_repository> that does not already exist in Bitbucket Server.

git clone --no-checkout --shared -b <source_branch> /var/atlassian/application-data/bitbucket/shared/data/repositories/<repository_id> /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git
 
cd /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git

git reset --quiet <target_branch_hash> --

git merge -m "Automatic merge" --no-ff --log <source_branch_hash>

Note that the Git repository itself will be left intact by these commands.

Last modified on Dec 23, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.