Review code in a pull request
We're in the process of updating Bitbucket's pull request experience. You may not have access to some features that we're currently working on:
- Ignore whitespace – May not yet be available.
- Hide word diff – May not yet be available.
- Tasks – May not yet be visible. However, if your admin sets a merge checklist item that requires all tasks to be resolved and you have open tasks, you'll need to need to resolve the task in the old view.
To find out if you have open tasks or get immediate access to these features from an individual pull request, go to> Open in old view.
Code review is an integral part of the pull request process, as well as the development process as a whole, and brings the following benefits to your team:
- Knowledge sharing—Because all code is reviewed by someone knowledgeable, it gives more developers a chance to work on something new and get feedback from others.
- Quality assurance—Even experienced developers are always learning and could use a few extra eyes on their code, ensuring that quality is at its highest.
- Mentorship opportunity—New team members who have just started delving into the codebase can learn lots from the feedback more seasoned members an provide.
Reviewing code in a pull request has two parts: 1) looking at the changes made and comparing it to the original code and 2) adding comments and feedback to start a discussion about code. For more details about what it means to be a pull request reviewer, see Reviewers in Review code in a pull request.
Looking at file diffs
Each pull request shows a diff of each file to compare the updates made to the repository and the repository or branch where the author wants to merge. Under Files changed on the Overview tab, you have a unified diff that shows the changes in one column by default.
From each file, you've got some options when reviewing the diff:
|Side-by-side diff||Compares the code changes in two columns. The left column (prior version) visually indicates the original set of code and the right column (new version) visually indicates the updates.|
|View file||Opens the file in the Source view. You'll see the full file and can make edits from Bitbucket.|
|Comment||Adds a comment to the file in the pull request. For other ways to comment on a pull request, see Comments.|
|Ignore whitespace||Removes any changes in the file that involve spaces and tabs from the diff view.|
|Hide word diff||Removes the darker shade of color that indicates the part of the line with changes.|
Discussing code and giving feedback
Comments and discussion are a large part of the code review process. As authors and reviewers comment and reply to the discussion, the author might push additional commits until the pull request is ultimately approved.
Anyone with write access to the repository can comment on a pull request. Pull requests have 3 different levels of comments:
- At the pull request as a whole
- On individual files
- On individual lines of code
No longer see an inline comment that was there previously?
Unless a user deleted the comment, it may still be there! When the content of a line gets removed, the comment becomes outdated. When this is the case, look for a button at the top of the file diff with a number. Clicking this button should reveal all comments on previous versons.
Anyone with write access to the repository can comment on a pull request.
To add a comment at each level:
- Pull request — Under Comments on the Overview tab, click the text field with What do you want to say?
- File — Click the Comment button above the file diff.
- Inline — Click the Add a comment to this line button next to the line.
To format your comments:
Use the formatting buttons at the top of the comment field or enter your comments in markdown.
To mention another user:
You can mention another user by entering the @ symbol and typing / selecting that user's name.
To take action on comments:
You've got links below the comment that gives you some options:
- Reply—Keeps the conversation going by opening another comment field.
- Edit—Reopens the comment field so you can make your updates and click Comment again. You can only edit your own comments.
- Delete—Permanently removes the comment from the pull request. Deleting a comment also removes it from the Activity.
Add one or more tasks to a comment to track required changes. Anyone can create a task from a comment, not just the comment creator. Tasks give pull request authors a list of action items that they need to complete as part of their code updates.
Repository admins can set a merge checklist item that requires all tasks to be resolved before the pull request is merged.
|Reviewers can...||Authors and repository admins can...|
To create a task:
If the exact text you want to use for a task is in the comment, highlight the text and click Create task. Otherwise, click Create task under the comment, enter the task description, and click Save.
To see a list of tasks in the pull request:
Look for the tasks link in the meta-data section on the right side, for example: 2 open tasks or All tasks resolved. Click that link to review all the open and resolved tasks. You'll only see this option if the pull request has tasks.