validate-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Validate the current Pull Request against Marshroom conventions.
Steps:
  1. Read
    ~/.config/marshroom/state.json
    and parse the JSON
  2. Run
    git branch --show-current
    to get the current branch name
  3. Find the cart entry whose
    branchName
    matches the current git branch. If no match, tell the user they're not on a cart issue branch
  4. Get the current PR info:
    gh pr view --json title,body,headRefName
  5. Validate the following:
Branch Name Check:
  • The PR's head branch should match the matched cart entry's
    branchName
  • Expected format:
    Feature/#N
    or
    HotFix/#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
    status
    field from the matched cart entry
  • After PR creation, status should be
    "pending"
  • If status is still
    "running"
    , warn that the status was not updated (suggest running
    marsh pr
    )
  • If status is
    "soon"
    , warn that
    /start-issue
    may not have been run
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。
步骤:
  1. 读取
    ~/.config/marshroom/state.json
    并解析该JSON文件
  2. 运行
    git branch --show-current
    获取当前分支名称
  3. 查找
    branchName
    与当前git分支匹配的cart条目。如果没有匹配项,告知用户当前不在cart问题分支上
  4. 获取当前PR信息:
    gh pr view --json title,body,headRefName
  5. 验证以下内容:
分支名称检查:
  • PR的源分支应与匹配到的cart条目中的
    branchName
    一致
  • 预期格式:
    Feature/#N
    HotFix/#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有效
  • 如果有任何检查失败,提供修复命令