GitLab CLI !4508 為堆疊式 MR 加入共用審查清單與個別説明
One review checklist, different context for every stacked GitLab MR
GitLab CLI !4508 為實驗性堆疊工作流程新增 --template 選項,建立 merge request 時可套用共用審查清單,並保留各提交內文作為該差異的專屬説明。範本可存於 .gitlab/merge_request_templates/Review.md;後續同步不會覆蓋已在 GitLab 編輯的描述,而範本名稱錯誤會在同步抓取或推送前報錯。
A stack splits one larger change into merge requests that can be reviewed in order. A shared checklist helps reviewers know what to look for, but each merge request still needs its own explanation. Otherwise, the reviewer opening the second MR has to infer what changed since the first.
GitLab CLI !4508 adds a way to supply that shared checklist when creating merge requests with the experimental stack workflow. It keeps the commit body for each diff, where the reason for that particular change belongs.
Give the stack a shared checklist
Start in a repository with an existing local stack. Save a template as .gitlab/merge_request_templates/Review.md with the prompts you want every reviewer to see. For example:
## Review checklist
- Check what this diff changes on its own.
- Check how to verify it before moving to the next diff.
Put the specific context after the blank line in each commit message. For example, a commit titled Extract the parser could have the body Moves parsing into its own package so the follow-up can change validation without moving code. The next commit can explain which input it validates and point to the relevant test. Each new MR gets the same checklist followed by its own commit body. A commit with an empty body gets just the template.
Check that your build has the flag with glab stack sync --help. Then, when you are ready to update your stack on GitLab:
glab stack sync --template Review
A plain name is looked up in the repository's template directory. The .md suffix is optional. An absolute path or a value containing a path separator is read as a file path.
What a second sync does
The template is used when a merge request is created. If you edit the description on GitLab, a later sync with a different template leaves that earlier description alone. A misspelled template name fails before sync fetches or pushes. With --skip-push or --skip-mr-creation, the command warns that it is ignoring the template. Those flags still have their normal sync behavior.
The regression tests cover two new merge requests receiving the same template with their respective commit bodies, a commit with no body, and a nonexistent template. I verified the command help against a build from upstream source. See the stack documentation for how each diff's target branch is selected.
AI assistance was used to prepare this article.
來源:DEV Community · dev.to