diff --git a/autoplan/SKILL.md b/autoplan/SKILL.md index 03624098..7ac2e552 100644 --- a/autoplan/SKILL.md +++ b/autoplan/SKILL.md @@ -259,22 +259,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/canary/SKILL.md b/canary/SKILL.md index 26868d55..c271db97 100644 --- a/canary/SKILL.md +++ b/canary/SKILL.md @@ -253,22 +253,42 @@ If `NEEDS_SETUP`: 2. Run: `cd && ./setup` 3. If `bun` is not installed: `curl -fsSL https://bun.sh/install | bash` -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/codex/SKILL.md b/codex/SKILL.md index 6b3d45c6..3401f411 100644 --- a/codex/SKILL.md +++ b/codex/SKILL.md @@ -253,22 +253,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/land-and-deploy/SKILL.md b/land-and-deploy/SKILL.md index 455658fa..11e32761 100644 --- a/land-and-deploy/SKILL.md +++ b/land-and-deploy/SKILL.md @@ -270,22 +270,42 @@ If `NEEDS_SETUP`: 2. Run: `cd && ./setup` 3. If `bun` is not installed: `curl -fsSL https://bun.sh/install | bash` -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index a274efc0..0173dbf9 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -257,22 +257,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index ce5f9e75..d479933f 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -255,22 +255,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/qa/SKILL.md b/qa/SKILL.md index b63d6fbd..099a1f8c 100644 --- a/qa/SKILL.md +++ b/qa/SKILL.md @@ -258,22 +258,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- diff --git a/retro/SKILL.md b/retro/SKILL.md index 14160554..b4a0fa74 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -234,13 +234,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Detect default branch +## Step 0: Detect platform and base branch -Before gathering data, detect the repo's default branch name: -`gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +First, detect the git hosting platform from the remote URL: -If this fails, fall back to `main`. Use the detected name wherever the instructions -say `origin/` below. +```bash +git remote get-url origin 2>/dev/null +``` + +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) + +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. + +Print the detected base branch name. In every subsequent `git diff`, `git log`, +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. --- @@ -311,8 +340,8 @@ git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n # 4. Files most frequently changed (hotspot analysis) git log origin/ --since="" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn -# 5. PR numbers from commit messages (extract #NNN patterns) -git log origin/ --since="" --format="%s" | grep -oE '#[0-9]+' | sed 's/^#//' | sort -n | uniq | sed 's/^/#/' +# 5. PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN) +git log origin/ --since="" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/' # 6. Per-author file hotspots (who touches what) git log origin/ --since="" --format="AUTHOR:%aN" --name-only @@ -783,8 +812,8 @@ git -C log origin/$DEFAULT --since="T00:00:00" --format="%at| # Per-author commit counts git -C shortlog origin/$DEFAULT --since="T00:00:00" -sn --no-merges -# PR numbers from commit messages -git -C log origin/$DEFAULT --since="T00:00:00" --format="%s" | grep -oE '#[0-9]+' | sort -n | uniq +# PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN) +git -C log origin/$DEFAULT --since="T00:00:00" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/' ``` For repos that fail (deleted paths, network errors): skip and note "N repos could not be reached." @@ -862,7 +891,7 @@ align cleanly. Never truncate project names. ║ • [1-line description of second theme] ║ • [1-line description of third theme] ║ -║ Powered by gstack · github.com/garrytan/gstack +║ Powered by gstack ╚═══════════════════════════════════════════════════════════════ ``` @@ -991,7 +1020,7 @@ Use the Write tool to save JSON to `~/.gstack/retros/global-${today}-${next}.jso "projects": [ { "name": "gstack", - "remote": "https://github.com/garrytan/gstack", + "remote": "", "commits": 47, "insertions": 3200, "deletions": 800, diff --git a/retro/SKILL.md.tmpl b/retro/SKILL.md.tmpl index 57a3759a..0dbfa91d 100644 --- a/retro/SKILL.md.tmpl +++ b/retro/SKILL.md.tmpl @@ -18,15 +18,7 @@ allowed-tools: {{PREAMBLE}} -## Detect default branch - -Before gathering data, detect the repo's default branch name: -`gh repo view --json defaultBranchRef -q .defaultBranchRef.name` - -If this fails, fall back to `main`. Use the detected name wherever the instructions -say `origin/` below. - ---- +{{BASE_BRANCH_DETECT}} # /retro — Weekly Engineering Retrospective @@ -95,8 +87,8 @@ git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n # 4. Files most frequently changed (hotspot analysis) git log origin/ --since="" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn -# 5. PR numbers from commit messages (extract #NNN patterns) -git log origin/ --since="" --format="%s" | grep -oE '#[0-9]+' | sed 's/^#//' | sort -n | uniq | sed 's/^/#/' +# 5. PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN) +git log origin/ --since="" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/' # 6. Per-author file hotspots (who touches what) git log origin/ --since="" --format="AUTHOR:%aN" --name-only @@ -567,8 +559,8 @@ git -C log origin/$DEFAULT --since="T00:00:00" --format="%at| # Per-author commit counts git -C shortlog origin/$DEFAULT --since="T00:00:00" -sn --no-merges -# PR numbers from commit messages -git -C log origin/$DEFAULT --since="T00:00:00" --format="%s" | grep -oE '#[0-9]+' | sort -n | uniq +# PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN) +git -C log origin/$DEFAULT --since="T00:00:00" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/' ``` For repos that fail (deleted paths, network errors): skip and note "N repos could not be reached." @@ -646,7 +638,7 @@ align cleanly. Never truncate project names. ║ • [1-line description of second theme] ║ • [1-line description of third theme] ║ -║ Powered by gstack · github.com/garrytan/gstack +║ Powered by gstack ╚═══════════════════════════════════════════════════════════════ ``` @@ -775,7 +767,7 @@ Use the Write tool to save JSON to `~/.gstack/retros/global-${today}-${next}.jso "projects": [ { "name": "gstack", - "remote": "https://github.com/garrytan/gstack", + "remote": "", "commits": 47, "insertions": 3200, "deletions": 800, diff --git a/review/SKILL.md b/review/SKILL.md index 912e1f3e..32e00202 100644 --- a/review/SKILL.md +++ b/review/SKILL.md @@ -255,22 +255,42 @@ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: file you are allowed to edit in plan mode. The plan file review report is part of the plan's living status. -## Step 0: Detect base branch +## Step 0: Detect platform and base branch -Determine which branch this PR targets. Use the result as "the base branch" in all subsequent steps. +First, detect the git hosting platform from the remote URL: -1. Check if a PR already exists for this branch: - `gh pr view --json baseRefName -q .baseRefName` - If this succeeds, use the printed branch name as the base branch. +```bash +git remote get-url origin 2>/dev/null +``` -2. If no PR exists (command fails), detect the repo's default branch: - `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` +- If the URL contains "github.com" → platform is **GitHub** +- If the URL contains "gitlab" → platform is **GitLab** +- Otherwise, check CLI availability: + - `gh auth status 2>/dev/null` succeeds → platform is **GitHub** (covers GitHub Enterprise) + - `glab auth status 2>/dev/null` succeeds → platform is **GitLab** (covers self-hosted) + - Neither → **unknown** (use git-native commands only) -3. If both commands fail, fall back to `main`. +Determine which branch this PR/MR targets, or the repo's default branch if no +PR/MR exists. Use the result as "the base branch" in all subsequent steps. + +**If GitHub:** +1. `gh pr view --json baseRefName -q .baseRefName` — if succeeds, use it +2. `gh repo view --json defaultBranchRef -q .defaultBranchRef.name` — if succeeds, use it + +**If GitLab:** +1. `glab mr view -F json 2>/dev/null` and extract the `target_branch` field — if succeeds, use it +2. `glab repo view -F json 2>/dev/null` and extract the `default_branch` field — if succeeds, use it + +**Git-native fallback (if unknown platform, or CLI commands fail):** +1. `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||'` +2. If that fails: `git rev-parse --verify origin/main 2>/dev/null` → use `main` +3. If that fails: `git rev-parse --verify origin/master 2>/dev/null` → use `master` + +If all fail, fall back to `main`. Print the detected base branch name. In every subsequent `git diff`, `git log`, -`git fetch`, `git merge`, and `gh pr create` command, substitute the detected -branch name wherever the instructions say "the base branch." +`git fetch`, `git merge`, and PR/MR creation command, substitute the detected +branch name wherever the instructions say "the base branch" or ``. ---