-
-
Notifications
You must be signed in to change notification settings - Fork 468
fix(skill): Detect stacked PR context from branch #5223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,15 +9,47 @@ Prepare local changes and create a pull request for the sentry-java repo. | |
|
|
||
| **Required reading:** Before proceeding, read `.cursor/rules/pr.mdc` for the full PR and stacked PR workflow details. That file is the source of truth for PR conventions, stack comment format, branch naming, and merge strategy. | ||
|
|
||
| ## Step 0: Determine PR Type | ||
| ## Step 0: Determine PR Type From Git Branch Context | ||
|
|
||
| Ask the user (or infer from context) whether this is: | ||
| Infer PR type from the current branch before asking the user. | ||
|
|
||
| - **Standalone PR** — a regular PR targeting `main`. Follow Steps 1–6 as written. | ||
| - **First PR of a new stack** — ask for a topic name (e.g. "Global Attributes"). Create a collection branch from `main`, then branch the first PR off it. The first PR targets the collection branch. | ||
| - **Next PR in an existing stack** — identify the previous stack branch and topic. This PR targets the previous stack branch. | ||
| 1. Get current branch: | ||
|
|
||
| If the user mentions "stack", "stacked PR", or provides a topic name with a number (e.g. `[Topic 2]`), treat it as a stacked PR. See `.cursor/rules/pr.mdc` § "Stacked PRs" for full details. | ||
| ```bash | ||
| git branch --show-current | ||
| ``` | ||
|
|
||
| 2. Apply these rules: | ||
|
|
||
| - **If branch is `main` or `master`**: default to a **standalone PR**. | ||
| - Do **not** assume stack mode from `main`. | ||
| - Only use stack mode if the user explicitly asks for a stacked PR. | ||
| - **If branch is not `main`/`master`**: | ||
| - Check whether that branch already has a PR and what its base is: | ||
| ```bash | ||
| gh pr list --head "$(git branch --show-current)" --json number,baseRefName,title --jq '.[0]' | ||
| ``` | ||
| - If that branch PR exists and `baseRefName` is **not** `main`/`master`, treat the work as a **stacked PR context**. | ||
| - If that branch PR exists and `baseRefName` **is** `main`/`master`, also check whether other PRs target the current branch: | ||
| ```bash | ||
| gh pr list --base "$(git branch --show-current)" --json number,headRefName,title | ||
| ``` | ||
| - If there are downstream PRs, treat this as **next PR in an existing stack** with the current branch as the stack base (collection branch). | ||
| - If there are no downstream PRs, treat it as **standalone PR context**. | ||
| - If no PR exists for the current branch, check whether other PRs target it: | ||
| ```bash | ||
| gh pr list --base "$(git branch --show-current)" --json number,headRefName,title | ||
| ``` | ||
| If there are downstream PRs, treat this as **next PR in an existing stack** with the current branch as the stack base (collection branch). | ||
|
|
||
|
Comment on lines
+39
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The decision tree for inferring PR type has a missing case for a non-main branch with no existing PR and no downstream PRs, forcing a fallback to user prompting. Suggested FixUpdate the decision tree in Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| 3. If signals are mixed or ambiguous, ask one focused question to confirm. | ||
|
|
||
| PR types: | ||
| - **Standalone PR** — regular PR targeting `main`. | ||
| - **First PR of a new stack** — create collection branch from `main`, then first PR off it. | ||
| - **Next PR in an existing stack** — target the current stack base branch (usually the previous stack PR branch, or the collection branch if creating the first follow-up PR from the collection branch). | ||
|
|
||
| If the user explicitly says "stack", "stacked PR", or provides numbered stack titles (e.g. `[Topic 2]`), honor that even if branch heuristics are inconclusive. | ||
|
|
||
| ## Step 1: Ensure Feature Branch | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing decision branch for fresh feature branches
Medium Severity
The decision tree for non-
mainbranches has a missing case: when no PR exists for the current branch and no downstream PRs target it. This is the most common scenario (a fresh feature branch before any PR is created). The "If no PR exists" block only handles the sub-case where downstream PRs exist but never specifies a fallback (e.g., defaulting to standalone PR) when no downstream PRs are found either. The catch-all "mixed or ambiguous" clause at step 3 doesn't naturally apply here since the signals aren't ambiguous — they're just absent.