npm run other:cherry-pick 可自动将带有特定标签的 Pull Request cherry-pick(挑选合并)到当前分支。
这对于主要的 WordPress 版本发布尤其有用,因为默认情况下,该脚本会查找已合并且带有 Backport to WP Beta/RC 标签的 Pull Request。
你也可以通过传递自定义标签作为第一个参数,将其用于不同的场景。请参阅本文档末尾的 Gutenberg 插件发布示例。
运行 npm run other:cherry-pick 会出现以下提示:
You are on branch "wp/6.2".
This script will:
• Cherry-pick the merged PRs labeled as "Backport to WP Beta/RC" to this branch
• Ask whether you want to push this branch
• Comment on each PR
• Remove the label from each PR
The last two actions will be performed USING YOUR GITHUB ACCOUNT that you've
linked to your GitHub CLI (gh command)
Do you want to proceed? (Y/n)
一旦你同意,将会发生以下操作:
Trying to cherry-pick one by one..
$ git pull origin wp/6.2 --rebase...
$ git fetch origin trunk...
Found the following PRs to cherry-pick:
#41198 – Site Editor: Set min-width for styles preview
Fetching commit IDs... Done!
#41198 – 860a39665c318d33027d – Site Editor: Set min-width for...
Trying to cherry-pick one by one...
Cherry-picking round 1:
cherry-pick commit: afe9b757b4 for PR: #41198 – Site Editor: Set min-width for...
Cherry-picking finished!
Summary:
1 PRs got cherry-picked cleanly
0 PRs failed
About to push to origin/wp/6.2
Do you want to proceed? (Y/n)
这次运行成功了,太棒了!你可以利用这个时刻确认正确的 PR 已被 cherry-pick。
如果 cherry-picks 未能干净地应用怎么办?脚本会应用其余部分并重试。
如果某些 cherry-picks 仍然失败,脚本将跳过它们并告知你需要手动解决哪些冲突。
无论哪种情况,一旦你通过 cherry-picking 阶段继续操作,将会发生以下情况:
Pushing to origin/wp/6.2
Commenting and removing labels...
41198: I just cherry-picked this PR to the wp/6.2 branch to get it included in the next release: afe9b757b4
Done!
评论部分是可选的,并且只有在你安装了 gh 控制台实用工具时才可用。
我可以使用不同于 Backport to WP Beta/RC 的标签吗?
可以!将其作为第一个参数传递:
npm run other:cherry-pick "Another Label"
如何将其用于 Gutenberg 插件发布?
# Switch to the release branch
git checkout release/X.Y
# Cherry-pick all the merged PRs with a relevant backport label
npm run other:cherry-pick "Backport to Gutenberg RC"
未来的改进
在未来,如果脚本能根据当前选定的分支自动选择相关标签,那就太好了:
- release/X.Y – 插件发布 – “Backport to Gutenberg RC”
- wp/X.Y – WP 发布 – “Backport to WP Beta/RC”