GitHub 推出 Stacked PRs 私人預覽,呼應 Phabricator 的堆疊式差異工作流
GitHub invokes spirit of Phabricator with preview of Stacked PRs
GitHub 推出仍處於私人預覽階段的 Stacked PRs,讓拉取請求建基於前一個請求形成堆疊,方便審核和管理大型變更。堆疊中的每個請求均可獨立審核及合併,但須先合併其下方請求;亦可一次合併整個堆疊。gh stack CLI 並非必需,用戶可透過 UI 建立堆疊式 PR;該 CLI 亦為 AI 智能體而設。
GitHub has unveiled Stacked PRs, a new feature aimed at making large pull requests easier to review, manage, and move through the pipeline faster.
Stacked PRs, now in private preview, enable a pull request to be based on a previous pull request to form a stack. Each pull request in the stack can be reviewed and merged independently, provided that all the pull requests below it in the stack are merged first. It is also possible to merge the whole stack together.
DEVCLASS AD
There are several benefits to Stacked PRs, the most obvious being that they encourage smaller pull requests, which are therefore easier to review. "Each branch in a stack should represent a discrete, logical unit of work that can be reviewed independently," the docs explain.
This is normally hard to achieve because developers typically want to continue working on code, even where the new code depends on earlier code that is not yet merged with the main branch. Waiting for each small piece to be reviewed and merged would cause too much delay, so instead they continue working in a separate branch until a feature is complete. The consequence is a large pull request with code changes in many files, which are hard to review.
The Stacked PRs feature is new to GitHub, but familiar from other code management and review systems, where it is often called stacked diffs. One well-known example was Differential, created by Facebook's Evan Priestley and Luke Shepard in 2007. "I was spending a lot of time waiting for code review to happen, which was a major motivator for building the tool," said Priestley. Differential became part of a suite of tools used by Facebook, called Phabricator, and was released as open source in 2011.
DEVCLASS AD
Open source Phabricator ceased development in 2021, though a fork called Phorge remains actively maintained.
The developer workflow when using Stacked PRs is substantially different from that used without them. The bottom PR in a stack is normally based on the main branch, rather than a separate branch. Jackson Gabbard, who was an engineer at Facebook between 2006 and 2016, wrote a detailed explainer in which he said "people who have worked with Phabricator using a 'stacked diff' workflow generally love it and seek it wherever they next go."
A discussion of the feature on Hacker News is generally positive, though a developer observed: "I don't quite see the need for this CLI [command line interface]. Git has had some additions in the last few years that make this work natively." The CLI referenced here is the new GitHub-specific extension gh stack. Nevertheless, building this into GitHub is a major change, and the CLI simplifies its use. GitHub's Sameen Karim, who has been working on the feature, said that "the CLI is completely optional, you can create stacked PRs purely via the UI."
GitHub also has AI in mind. "The bottleneck is no longer writing code – it's reviewing it. Stacks help solve that," said Karim on LinkedIn. The stack CLI is also designed for use by AI agents, Karim said.
來源:DevClass · devclass.com