Docs say a PR from a linked branch is "automatically linked" to the issue, but it is not when the PR targets a non-default branch

オープン 初心者向け
#45,948 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
github
領域
documentation

調査の方向性

レポートにリンクされている creating-a-branch-for-an-issue の記事から始め、そこにある自動リンクに関する記述を、リンクされているプルリクエストの記事と比較します。文書化されているデフォルトブランチの条件を確認し、該当する箇所を観測された動作に一致するよう更新します。記事が自動リンクが発生するタイミングを明確に説明し、関連するドキュメントチェックに合格すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

builder persona triage
Code of Conduct
What article on docs.github.com is affected?

https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-a-branch-for-an-issue

What part(s) of the article would you like to see updated?

The article states, with no condition on the pull request's base branch:

When you create a pull request for a branch that's connected to an issue, it is automatically linked to the issue, and the connection with that branch is removed with only the pull request shown in the "Development" section.

In practice this automatic linking does not happen when the pull request targets a branch other than the repository's default branch. The article should either state that the automatic linking requires the pull request to target the default branch, or the behaviour should be changed to match the current wording.

For comparison, the default-branch requirement is documented for closing keywords on Linking a pull request to an issue ("The pull request must be on the default branch."). There is no equivalent caveat on this page, so readers who create a branch from an issue reasonably expect the link to be created regardless of the base branch.

Additional information

Steps to reproduce (reproduced reliably, on a repository whose default branch is main):

  1. Create issue A. From its Development section, use "Create a branch" to create linked branch feature/a.
  2. Create issue B. Create linked branch feature/b the same way, based on feature/a.
  3. Push a commit to feature/b and open a pull request from feature/b with base feature/a (a stacked pull request).

Expected (per the article): issue B's Development section shows the pull request in place of the branch, and the pull request's closingIssuesReferences contains issue B.

Actual: issue B's Development section still shows the branch, and no pull request appears there. The pull request's closingIssuesReferences is empty, and no connected event is emitted on the issue timeline — only cross-referenced.

Repeating step 3 with base = main behaves exactly as documented: a connected event is emitted about two seconds after the pull request is created, and the branch entry is replaced by the pull request.

Notes

  • Manually linking that same pull request to the issue from the Development sidebar does work with a non-default base, and the resulting link is a normal one (closingIssuesReferences becomes populated). So this is not a blanket restriction on non-default base branches — only the automatic linking silently does not run. That asymmetry is what makes the current wording misleading.
  • Why this matters: in a stacked pull request workflow every pull request except the first one targets a non-default branch, so each one silently loses its issue link. Nothing in the UI indicates that the link is missing; it is only visible by querying closingIssuesReferences through the API, or by noticing that the Development section still lists a branch rather than a pull request.
  • Related, but not the same request: https://github.com/orgs/community/discussions/13240 asks for linked issues to be closed when a pull request merges into a non-default branch. This report is about the link not being created at all, which happens even before any merge.
主要言語
TypeScript
スター
20.9k
フォーク
68.8k
平均マージ
13時間 55分
マージ済み PR(30日)
105

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/docs のほかの issue

github/docs の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。