mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 11:45:20 +02:00
feat: GitLab support in /retro — use shared BASE_BRANCH_DETECT resolver
Replace retro's custom gh-only default branch detection with the shared BASE_BRANCH_DETECT resolver (DRY — same as 10 other skills). Update PR/MR number extraction to match both GitHub #NNN and GitLab !NNN patterns. Remove hardcoded github.com URL from the personal card footer. Regenerate all SKILL.md files affected by the resolver update. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -253,22 +253,42 @@ If `NEEDS_SETUP`:
|
||||
2. Run: `cd <SKILL_DIR> && ./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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -270,22 +270,42 @@ If `NEEDS_SETUP`:
|
||||
2. Run: `cd <SKILL_DIR> && ./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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+40
-11
@@ -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/<default>` 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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
@@ -311,8 +340,8 @@ git log origin/<default> --since="<window>" --format="%at|%aN|%ai|%s" | sort -n
|
||||
# 4. Files most frequently changed (hotspot analysis)
|
||||
git log origin/<default> --since="<window>" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn
|
||||
|
||||
# 5. PR numbers from commit messages (extract #NNN patterns)
|
||||
git log origin/<default> --since="<window>" --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/<default> --since="<window>" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/'
|
||||
|
||||
# 6. Per-author file hotspots (who touches what)
|
||||
git log origin/<default> --since="<window>" --format="AUTHOR:%aN" --name-only
|
||||
@@ -783,8 +812,8 @@ git -C <path> log origin/$DEFAULT --since="<start_date>T00:00:00" --format="%at|
|
||||
# Per-author commit counts
|
||||
git -C <path> shortlog origin/$DEFAULT --since="<start_date>T00:00:00" -sn --no-merges
|
||||
|
||||
# PR numbers from commit messages
|
||||
git -C <path> log origin/$DEFAULT --since="<start_date>T00:00:00" --format="%s" | grep -oE '#[0-9]+' | sort -n | uniq
|
||||
# PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN)
|
||||
git -C <path> log origin/$DEFAULT --since="<start_date>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": "<detected from git remote get-url origin, normalized to HTTPS>",
|
||||
"commits": 47,
|
||||
"insertions": 3200,
|
||||
"deletions": 800,
|
||||
|
||||
+7
-15
@@ -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/<default>` below.
|
||||
|
||||
---
|
||||
{{BASE_BRANCH_DETECT}}
|
||||
|
||||
# /retro — Weekly Engineering Retrospective
|
||||
|
||||
@@ -95,8 +87,8 @@ git log origin/<default> --since="<window>" --format="%at|%aN|%ai|%s" | sort -n
|
||||
# 4. Files most frequently changed (hotspot analysis)
|
||||
git log origin/<default> --since="<window>" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn
|
||||
|
||||
# 5. PR numbers from commit messages (extract #NNN patterns)
|
||||
git log origin/<default> --since="<window>" --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/<default> --since="<window>" --format="%s" | grep -oE '[#!][0-9]+' | sed 's/^[#!]//' | sort -n | uniq | sed 's/^/#/'
|
||||
|
||||
# 6. Per-author file hotspots (who touches what)
|
||||
git log origin/<default> --since="<window>" --format="AUTHOR:%aN" --name-only
|
||||
@@ -567,8 +559,8 @@ git -C <path> log origin/$DEFAULT --since="<start_date>T00:00:00" --format="%at|
|
||||
# Per-author commit counts
|
||||
git -C <path> shortlog origin/$DEFAULT --since="<start_date>T00:00:00" -sn --no-merges
|
||||
|
||||
# PR numbers from commit messages
|
||||
git -C <path> log origin/$DEFAULT --since="<start_date>T00:00:00" --format="%s" | grep -oE '#[0-9]+' | sort -n | uniq
|
||||
# PR/MR numbers from commit messages (GitHub #NNN, GitLab !NNN)
|
||||
git -C <path> log origin/$DEFAULT --since="<start_date>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": "<detected from git remote get-url origin, normalized to HTTPS>",
|
||||
"commits": 47,
|
||||
"insertions": 3200,
|
||||
"deletions": 800,
|
||||
|
||||
+30
-10
@@ -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 `<default>`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user