Sub topic 10
Reviewing changes with pull requests
This chapter covers how DevOps Center uses pull requests to review a work item's changes before they move on. It assumes you can already create a work item, make changes in a development environment, and commit them to the work item branch. It also assumes you know Git basics: branches, commits, and merges.
Why the pull request is the review step
In a change set process, a second person rarely sees what is about to deploy. In DevOps Center, every work item has its own Git branch. A pull request (PR) proposes merging that branch into the branch that represents the first pipeline stage. The PR is where reviewers see the exact metadata differences, comment on them, and approve or reject.
DevOps Center creates and manages the PR through your Git provider, for example GitHub. The review itself happens in the provider's interface, using its normal tools: line comments, required reviewers, status checks, and branch protection.
Where the pull request sits in the flow
A work item moves through a fixed sequence of states. The PR sits between committing changes and the first merge into the pipeline.
If a reviewer asks for changes, you do not open a new PR. You commit more changes to the same work item branch, and the existing PR updates.
Creating the pull request
You create the PR from the work item in DevOps Center, after you have committed changes.
- Open the project and select the work item.
- Confirm the Changes tab shows your committed components and no remaining uncommitted ones.
- Select Review Changes (the label can vary slightly by release) and then create the pull request.
- Enter a title and description. The work item name is a good starting title, and the description should say what changed and why.
- Submit. DevOps Center opens the PR in your Git provider and links it to the work item.
The work item's status moves to a review state. The PR link on the work item gives reviewers a direct path to the diff.
What goes into the PR
The PR contains only what was committed to the work item branch. Changes that exist in the development sandbox but were never pulled and committed do not appear. If a reviewer asks "where is the field?", check whether the change was committed.
A good PR description includes:
- The business reason for the change.
- The components touched, in plain words.
- Anything a deployer must do by hand, such as a data load or a permission assignment.
- How you tested it.
Reading the diff for Salesforce metadata
Metadata diffs differ from application code diffs. A few patterns come up often.
| Pattern in the diff | What it usually means | What to check |
|---|---|---|
| Whole file shows as changed | Line endings or key order changed | Ask the author to retrieve again, and look for noise |
| Profile with many added lines | Unrelated permissions came along | Confirm only intended entries changed |
| Flow file with large changes | Flow versions are stored as full XML | Open the flow in the org, compare behavior |
| Deleted file in the diff | A component removal | Confirm it is intended and not a retrieve gap |
| Apex class changed, no test change | Coverage might drop | Check the test results for the stage |
Reviewers should read the diff with these questions in mind: Does each change match the work item description? Is anything included that should not be? Will this deploy to the next environment without manual setup?
Reviewers, approvals, and branch protection
DevOps Center does not define its own approval rules. It relies on your Git provider. That means review policy lives in repository settings, not in the DevOps Center pipeline.
Common controls in GitHub:
- Required approvals: block merging until a set number of people approve.
- Code owners: require review from specific people for certain paths, such as
force-app/main/default/classes. - Required status checks: block merging until automated checks pass.
- Restricted merge permissions: limit who can click merge.
Use branch protection on every stage branch, not only the final one. A PR into an early stage branch is the cheapest place to catch a problem.
Automated checks on the PR
You can attach automated checks to the PR through your provider, for example GitHub Actions. Typical checks for Salesforce include:
- A validation-only deployment against a scratch org or sandbox.
- Apex tests.
- Static analysis such as PMD or ESLint for Lightning Web Components.
The Salesforce CLI command below validates a deployment without saving it. A check could run the same command, or you can run it by hand before asking for review.
sf project deploy start --source-dir force-app --target-org uat --dry-run --test-level RunLocalTestsThe --dry-run flag validates only. RunLocalTests runs all local Apex tests, which is the usual level for production-bound changes. Running it before you request review shortens the review cycle.
To see what a promotion would carry beyond what has already reached the main branch, compare stage branches:
git fetch origin
git log --oneline origin/main..origin/UATResponding to review feedback
When a reviewer requests changes:
- Return to the development environment tied to the work item.
- Make the fix in the org.
- In DevOps Center, pull the new changes and commit them to the work item branch.
- The PR updates with the new commits. Reply to the review comments.
Avoid pushing fixes directly to the work item branch from a local clone unless your team has agreed on it. Direct pushes can leave the sandbox out of step with Git, and the next pull from the org may overwrite or conflict with your edits.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| No pull request option | Nothing is committed on the work item | Pull and commit changes first |
| PR shows unrelated files | Another work item shares the sandbox, or broad retrieve | Split the work, or remove the extra components before committing |
| PR cannot merge | Branch protection or conflicts with the target branch | Satisfy required checks, or resolve conflicts |
| Reviewer cannot open the PR | Missing repository access | Grant access in the Git provider |
| Status stays in review after merge | Merge happened outside DevOps Center and the tool has not refreshed | Refresh the work item, and check the PR state |
Merging the PR directly in the provider can work, but doing it from DevOps Center keeps the work item status accurate. Pick one path and keep to it.
Review practices that hold up
- Keep work items small. A PR with five components is reviewable. A PR with eighty is not.
- Require at least one reviewer who did not author the change.
- Write the description for someone who has not seen the sandbox.
- Treat profile and permission set changes with extra care, since they affect access.
- Do not use the PR to debug. If tests fail, fix them and push the result.
Exercise
A reviewer says the pull request is missing a validation rule you remember creating. The rule exists in your development sandbox. What is the most likely cause, and what do you do?
Show answer
The rule was not pulled and committed to the work item branch, so it is not in the PR. Open the work item, find the rule among the uncommitted changes, select it, and commit it. The existing PR updates with the new commit, and the reviewer can see the rule in the diff.
Exercise
Your team wants every PR into the UAT stage branch to need one approval and a passing validation deployment. Where do you configure this, and why not in the DevOps Center pipeline?
Show answer
Configure it in the Git provider as branch protection on the UAT branch, with one required approval and a required status check that runs the validation. DevOps Center has no separate approval rules. It merges through the provider, so the provider's rules decide whether a merge is allowed.