Issues and pull requests / Pull requests
Link the issues a pull request fixes
You open a pull request for an issue. You want the issue to close when the fix merges, and you want people who read the issue to see the pull request.
4 min read
Link the issue to the pull request. The link shows on both pages, and the merge closes the issue.
You need to be the author of the pull request, or to have triage access, to change its links.
1. Link the issue when you open the pull request
Push your branch. Then, in your clone, run:
src pr create --fill --fixes 12
--fixestakes one or more issue numbers, such as--fixes 12,13or--fixes "#12". You can give the flag more than one time.- A closing keyword in the title or the body links the issue too:
Fixes #12,Closes #12orResolves #12, in upper or lower case. This is also true for a pull request that GitHub sync brings in. - One pull request fixes 50 issues at most.
Important
Each number of --fixes must be an issue of this repository that you can read. If a number is a pull request or no issue, the forge refuses it and opens no pull request. A keyword that names such a number links nothing.
2. Change the links later
In a terminal:
src pr edit 7 --add-fixes 12
src pr edit 7 --remove-fixes 13
On the web:
- Open the pull request.
- On the Status tab of the right column, find the Fixes row of the Details card. Click its pencil.
- Type the issue numbers, for example
12, 13. Then click Link. - To remove a link, click the x next to the issue.
When an edit adds a closing keyword to the title or the body, the forge links that issue. When you remove the keyword, the link stays. Remove it with --remove-fixes.
3. See the links
- The Fixes row of the pull request lists the issues, each with its state.
- The sidebar of the issue lists the pull requests that fix it, under Pull requests.
- The list of issues shows, on each issue, the open pull requests that fix it and that you can read.
- Each change of a link adds a line to the timeline of the pull request and of the issue.
In the list of issues, one pull request shows as a link, such as #7, with its title on hover. Two or more show a count: click it to see the links. Merged and closed pull requests do not show, and the row changes live when one closes, merges or reopens.
In a terminal:
src pr view 7 --json closingIssuesReferences
src issue view 12 --json closedByPullRequestsReferences
4. Merge
When the pull request merges into the default branch, the forge closes each open issue that it fixes. The timeline of the issue says "closed this with #7".
- A merge into another branch closes no issue.
- Does your repository close issues only after the deploy job? Then the merge marks each issue Staged, and the issue stays open until the release. See Close fixed issues when the fix is live.
- Is your repository synced with GitHub? Then GitHub closes the issues. See Issues that a pull request fixes.
Done
Your pull request names the issues that it fixes. People who open the issue see the pull request, and the merge closes the issue without a manual step.
Later: REST and MCP
An agent or a script links issues over REST or MCP, with the same rules. The REST paths are under /api/v1/repos/{owner}/{repo}.
| You want to | REST | MCP tool |
|---|---|---|
| Link issues when you open the pull request | POST /pulls, with "fixes": [12] | create_pull_request, with fixes |
| Make a list the exact links | PUT /pulls/{n}/fixes, with { "issues": [12, 13] } | set_pull_fixes, with mode: "set" |
| Add links | POST /pulls/{n}/fixes, with { "issues": [12] } | set_pull_fixes, with mode: "add" |
| Remove a link | DELETE /pulls/{n}/fixes/{issue} | set_pull_fixes, with mode: "remove" |
| Read the links | GET /issues/{n} | get_issue |
GET /issues/{n} of a pull request has fixes, the issues that it fixes. For an issue, it has fixedBy, the pull requests that fix it, and staged.
The token of a CI job cannot change links.