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 從公開儲存庫中收錄這些內容。

檢舉或申請下架