validate-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseValidate the current Pull Request against Marshroom conventions.
Steps:
- Read and parse the JSON
~/.config/marshroom/state.json - Run to get the current branch name
git branch --show-current - Find the cart entry whose matches the current git branch. If no match, tell the user they're not on a cart issue branch
branchName - Get the current PR info:
gh pr view --json title,body,headRefName - Validate the following:
Branch Name Check:
- The PR's head branch should match the matched cart entry's
branchName - Expected format: or
Feature/#NHotFix/#N - If mismatched, show: "Branch mismatch: expected '{branchName}', got '{actual}'"
PR Body Check:
- The body MUST contain
close #{issueNumber} - If missing, suggest:
gh pr edit --body "$(gh pr view --json body -q '.body')\n\nclose #<issueNumber>"
Status Check:
- Read the field from the matched cart entry
status - After PR creation, status should be
"pending" - If status is still , warn that the status was not updated (suggest running
"running")marsh pr - If status is , warn that
"soon"may not have been run/start-issue
Summary:
- Show pass/fail status for each check
- If all checks pass, confirm the PR is valid
- If any check fails, provide the fix commands
根据Marshroom规范验证当前Pull Request。
步骤:
- 读取并解析该JSON文件
~/.config/marshroom/state.json - 运行获取当前分支名称
git branch --show-current - 查找与当前git分支匹配的cart条目。如果没有匹配项,告知用户当前不在cart问题分支上
branchName - 获取当前PR信息:
gh pr view --json title,body,headRefName - 验证以下内容:
分支名称检查:
- PR的源分支应与匹配到的cart条目中的一致
branchName - 预期格式:或
Feature/#NHotFix/#N - 如果不匹配,显示:"分支不匹配:预期为'{branchName}',实际为'{actual}'"
PR正文检查:
- 正文必须包含
close #{issueNumber} - 如果缺失,建议执行:
gh pr edit --body "$(gh pr view --json body -q '.body')\n\nclose #<issueNumber>"
状态检查:
- 从匹配到的cart条目中读取字段
status - 创建PR后,状态应设为
"pending" - 如果状态仍为,警告用户状态未更新(建议运行
"running")marsh pr - 如果状态为,警告用户可能未运行
"soon"/start-issue
总结:
- 显示每项检查的通过/失败状态
- 如果所有检查通过,确认PR有效
- 如果有任何检查失败,提供修复命令