Pr Link Issue

作者 getsentryd18b7aa8ba87无许可证1K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5天前更新

Append a GitHub issue link and its Linear ticket to the current PR's description. Use when asked to "link issue to pr", "fill in issue and linear in pr", "add issue refs to pr", or when given a GitHub issue URL and asked to attach it to the current PR. Resolves the Linear ticket automatically from the issue's linear-linkback comment.

AI 生成的概览

将 GitHub issue 链接及其 Linear 工单追加到当前 PR 描述中。

功能
该技能会向拉取请求描述追加一个 Sentry 风格的 Issues 区块,引用 GitHub issue 以及从该 issue 的 linear-linkback 评论中获取的 Linear 工单。它会从当前分支解析 PR 编号,从输入中提取 issue 编号和仓库,并在追加或替换 Issues 部分之前先读取现有 PR 正文。随后更新 PR 正文,并通过输出生成的 PR URL 进行确认。
适用场景
当被要求将 issue 链接到 PR、在 PR 中填写 issue 和 Linear 引用,或将给定的 GitHub issue URL 附加到当前拉取请求时使用。它适用于 PR 描述需要同时引用 GitHub issue 及其 Linear 工单的场景。
运行要求
需要已通过身份验证且可访问该仓库的 GitHub CLI(gh),以及访问 GitHub 的网络连接。Linear 工单的解析依赖由 linear-code 用户发布的 linear-linkback 评论;若不存在,则会向用户询问该键值或将其省略。仅为指令,不附带脚本。

Link a GitHub Issue + Linear Ticket on a PR

Appends a Sentry-style #### Issues block to a PR description, referencing both the GitHub issue and the Linear ticket pulled from the issue's linear-linkback comment.

Inputs

  • <issue-url> — GitHub issue URL like https://github.com/<owner>/<repo>/issues/<n>. Issue number alone is fine if the PR is in the same repo.
  • (optional) <pr-number> — defaults to the open PR for the current branch.

Steps

  1. Resolve the PR number — skip if user supplied one:

    bash
    gh pr view --json number,body -q '.number'

    If no PR exists on the branch, stop and tell the user.

  2. Extract issue number + repo from the input URL, or accept a bare #1234 for current repo.

  3. Fetch the Linear ticket from the issue's linear-linkback comment:

    bash
    gh issue view <n> --repo <owner>/<repo> --json comments \  -q '.comments[] | select(.author.login=="linear-code") | .body' \  | grep -Eioe '[a-z]+-[0-9]+' | head -1

    If no match, fall back to asking the user for the Linear key, or omit it.

  4. Read the existing PR body so you can append rather than overwrite:

    bash
    gh pr view <pr-number> --json body -q '.body'
  5. Construct the new body. If the body is empty, use just the #### Issues block. Otherwise, append it after a blank line. Don't duplicate — if #### Issues is already present, replace that section instead of adding a second one.

    Format:

    markdown
    #### Issues
    * Resolves: #<n>* Resolves: <linear-key>
  6. Update the PR with a heredoc to preserve newlines:

    bash
    gh pr edit <pr-number> --body "$(cat <<'EOF'<new body>EOF)"
  7. Confirm by echoing the resulting PR URL:

    bash
    gh pr view <pr-number> --json url -q '.url'

Notes

  • Linear linkback comments are posted by the GitHub user linear-code. The body contains a markdown link whose text is the Linear key, e.g. PY-2357.
  • Project keys vary per repo (PY-… for sentry-python, JS-… for sentry-javascript, etc.) — the regex [a-z]+-[0-9]+ covers them.
  • Don't strip existing PR content. Always read first, append/replace second.
  • If the issue doesn't have a Linear linkback yet (newly filed), proceed with just the GitHub issue reference and tell the user the Linear key is missing.

来源与署名

来源:getsentry/skills位于skills/pr-link-issue提交d18b7aa

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架