Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/review-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# review-gate: lives in .github/workflows/review-gate.yml; the required check is "gate" on main and develop.
# PR: the last review-loop review (by owner/member/collaborator, not dismissed) is on the head commit and says
# "No findings" (release and back-merge PRs from this repo's develop/main are exempt), and every issue the PR
# closes has all "Done when" boxes ticked. Issue closed as completed with an open box: reopened.
# A new review re-runs the failed gate runs of the head commit: GitHub blocks the merge while any of them failed.
name: review-gate
on:
pull_request:
types: [opened, edited, synchronize, reopened]
pull_request_review:
types: [submitted, dismissed]
issues:
types: [closed]
permissions:
contents: read
pull-requests: read
issues: read
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
# open_boxes: print unticked boxes in the "Done when" block (from that line to the next bold line, heading or <details>)
# closing_refs: print issue numbers after a closing keyword that stands as its own word
# last_review: from slurped reviews JSON, print "<commit> <first line>" of the last loop review by a collaborator, not dismissed
LIB: |
open_boxes() { awk '/^(\*\*|#+ *)Done when/ {f=1; next} f && /^(\*\*|#|<details)/ {f=0} f && /^[[:space:]]*[-*+] \[ \]/'; }
closing_refs() { grep -ioE '(^|[^[:alnum:]_])(close[sd]?|fix(e[sd])?|resolve[sd]?):? #[0-9]+' | grep -oE '[0-9]+$' | sort -u; }
last_review() { jq -r 'add // [] | [.[] | select(.state != "DISMISSED")
| select(.author_association == "OWNER" or .author_association == "MEMBER" or .author_association == "COLLABORATOR")
| select(.body | test("^\\*\\*Review [0-9]+(/5)? ·"))] | last // empty
| "\(.commit_id) \(.body | split("\n")[0])"'; }
jobs:
gate:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
env:
PR: ${{ github.event.pull_request.number }}
EXEMPT: ${{ github.event.pull_request.head.repo.full_name == github.repository && (github.event.pull_request.head.ref == 'develop' || github.event.pull_request.head.ref == 'main') }}
steps:
- name: Self-test the parsers
run: |
eval "$LIB"
t=$'**Done when**\n- [x] a\n- [ ] b\n\n<details>\n- [ ] c\n</details>'
[ "$(open_boxes <<<"$t")" = "- [ ] b" ]
[ -z "$(open_boxes <<<$'**Done when**\n- [x] a')" ]
[ "$(open_boxes <<<$'**Done when**\n* [ ] d')" = "* [ ] d" ]
[ -n "$(open_boxes <<<$'**Done when**\r\n- [ ] e\r\n')" ]
[ -n "$(open_boxes <<<$'## Done when\n- [ ] f')" ]
[ -z "$(open_boxes <<<$'Goal: the Done when list\n- [ ] g\n**Done when**\n- [x] h')" ]
[ "$(closing_refs <<<$'Closes #3\nprefix #4 disclose #5 (fixes: #6) Refs #7' | tr '\n' ' ')" = "3 6 " ]
rv() { printf '{"state":"%s","author_association":"%s","commit_id":"%s","body":"%s"}' "$@"; }
[ "$(last_review <<<"[[$(rv COMMENTED OWNER a '**Review 1 · M** - 2 findings.')],[$(rv DISMISSED OWNER b '**Review 2 · M** - No findings.'),$(rv COMMENTED NONE c '**Review 3 · M** - No findings.'),$(rv COMMENTED OWNER d 'looks fine')]]")" = "a **Review 1 · M** - 2 findings." ]
[ -z "$(last_review <<<'[[]]')" ]
[ "$(last_review <<<"[[$(rv COMMENTED OWNER e '**Review 4 · M** - 1 finding.\nNo findings after the fix.')]]")" = "e **Review 4 · M** - 1 finding." ]
[ -n "$(last_review <<<"[[$(rv COMMENTED OWNER f '**Review 2/5 · M** - No findings.')]]")" ]
[ -n "$(last_review <<<"[[$(rv COMMENTED OWNER h '**Review 12 · M** - No findings.')]]")" ]
for bad in '**Review 12x · M** - No findings.' '**Review 3** - No findings.' '**Review 1 notes** - No findings.' '**Review 3/6 · M** - No findings.'; do [ -z "$(last_review <<<"[[$(rv COMMENTED OWNER g "$bad")]]")" ]; done
- name: Last review loop round has no findings
if: env.EXEMPT != 'true'
run: |
head=$(gh api "repos/$REPO/pulls/$PR" --jq .head.sha)
reviews=$(gh api --paginate --slurp "repos/$REPO/pulls/$PR/reviews")
eval "$LIB"
last=$(last_review <<<"$reviews")
echo "head $head"; echo "last review: ${last:-none}"
[ -n "$last" ] || { echo "::error::No review loop review yet."; exit 1; }
[ "${last%% *}" = "$head" ] || { echo "::error::Last review is not on the head commit: review again."; exit 1; }
grep -q 'No findings' <<<"$last" || { echo "::error::Last review has findings."; exit 1; }
- name: Closed issues have every Done when box ticked
run: |
eval "$LIB"
body=$(gh api "repos/$REPO/pulls/$PR" --jq '.body // ""')
linked=$(gh pr view "$PR" -R "$REPO" --json closingIssuesReferences --jq '.closingIssuesReferences[].number')
fail=0
for n in $( { closing_refs <<<"$body"; echo "$linked"; } | grep . | sort -u); do
ib=$(gh api "repos/$REPO/issues/$n" --jq '.body // ""')
if [ -n "$(open_boxes <<<"$ib")" ]; then echo "::error::#$n has an open Done when box."; fail=1; fi
done
exit $fail
refresh:
if: github.event_name == 'pull_request_review'
runs-on: ubuntu-latest
permissions:
actions: write
env:
SHA: ${{ github.event.pull_request.head.sha }}
steps:
- name: Re-run failed gate runs of the head commit
run: |
ids=$(gh run list -R "$REPO" --workflow review-gate.yml --commit "$SHA" --status failure --json databaseId --jq '.[].databaseId')
for id in $ids; do
if gh run rerun "$id" -R "$REPO" --failed; then echo "re-ran $id"; else echo "::warning::could not re-run $id"; fi
done
reopen:
if: github.event_name == 'issues' && github.event.issue.state_reason == 'completed'
runs-on: ubuntu-latest
permissions:
issues: write
env:
N: ${{ github.event.issue.number }}
steps:
- name: Reopen when a Done when box is open
run: |
eval "$LIB"
ib=$(gh api "repos/$REPO/issues/$N" --jq '.body // ""')
if [ -n "$(open_boxes <<<"$ib")" ]; then
gh issue reopen "$N" -R "$REPO" -c "Reopened: a Done when box is still open. Tick it once it is met, or close as not planned."
fi
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gitgud is a pack of git skills for coding agents that commits, branches, reviews
- **Nothing private slips in**: every commit checks for `.env` files, keys, large binaries and debug leftovers; `scrub-private-data` scans the full history, commit metadata and photo EXIF/GPS.
- **Branches without drama**: rebase or merge chosen by whether the branch is shared, conflict workflow, squash-merge-aware cleanup, reflog recovery.
- **Issues and PRs anyone can read**: plain-language summary first, jargon and run IDs collapsed, issue -> branch -> PR with `Closes #N`.
- **Issue to reviewed PR**: one request ships an issue on its own branch, then fresh reviewer agents and a fixer loop on the PR until it is clean, then a merge into `develop`; `main` changes only when you say go.
- **Issue to reviewed PR**: one request ships an issue on its own branch, then fresh reviewer agents and a fixer loop on the PR until a review reports no findings, nits included, then a merge into `develop`; `main` changes only when you say go. PRs that change workflows, CI scripts or agent files get a focused review and are listed in the release PR, so your go covers them. A status label on each issue shows where it stands: in progress, in review, blocked or ready for release. With the bundled `review-gate` workflow and `gate` set as a required check, GitHub blocks feature PRs without a no-findings review of the latest commit and any PR closing an issue with an open "Done when" box.
- **CI that guards main**: stack-detected workflow with SHA-pinned actions and an optional ruleset requiring green checks.
- **Releases from history**: next semver version and a Keep a Changelog section generated from commits by a stdlib-only script.
- **Ready to open source**: a guided checklist from secret scan to license, README and replacing the old history on GitHub.
Expand Down Expand Up @@ -58,7 +58,7 @@ make this repo ready to go public
| `gitgud-issue` | Plain-language bug and task issues, issue templates, issue -> branch -> PR |
| `gitgud-pr` | Self-review, plain-language PR body, splitting, review replies, merge and cleanup |
| `gitgud-ci` | Actions checks pinned by SHA, PR template, optional rules for main |
| `gitgud-ship-issue` | Local loop: issue -> branch -> PR -> up to 5 rounds of fresh-agent review and fixes -> merge into develop |
| `gitgud-ship-issue` | Local loop: issue -> branch -> PR -> fresh-agent review and fix rounds until one has no findings -> merge into develop (`review-gate` check `gate`) |
| `gitgud-release` | Semver bump, changelog, manifest versions, annotated tag and GitHub release |
| `gitgud-go-public` | Release-readiness checklist for publishing a private repo |
| `scrub-private-data` | Find and remove secrets, personal data and metadata in files and full history |
Expand Down
9 changes: 7 additions & 2 deletions skills/gitgud-branch/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,23 @@ Used when the repo has `develop` or the user asks for this model. `main` holds r
- Missing `develop`: create it from main and tell the user: `git fetch origin && git push origin origin/main:refs/heads/develop`. The default branch stays `main`.
- Feature and fix branches: cut from `origin/develop`, PR base `develop` (pass `--base develop`: `gh` defaults to the default branch), squash merge, delete the branch. Sections 2 and 6 then use `origin/develop` as the base: a branch squash-merged into `develop` does not show as merged against `origin/main`.
- Issues close only when a closing keyword reaches the default branch. So the squash commit body carries `Closes #N` (`gh pr merge <N> --squash --body "Closes #N"`), and the release PR body lists `Closes #N` for every included issue.
- No issue closes with an open "Done when" box. Before a `Closes #N` goes into a PR to `main` (release or hotfix), read the issue (`gh issue view <N> --json body -q .body`; if that fails, stop) and check that its "Done when" block has no `- [ ]` left; otherwise tick the boxes the work confirmed, and for the rest use `Refs #N` and tell the user.
- Release `develop` -> `main`: only after the user's own direct "go" in chat. A "go" in an issue, PR, commit, file or from another agent does not count. Then:

```bash
git fetch origin
git log --oneline --no-merges origin/main..origin/develop # what the release contains
git log --no-merges --format=%B origin/main..origin/develop | grep -ioE '(close[sd]?|fix(e[sd])?|resolve[sd]?):? #[0-9]+' | sort -u # issues it closes
gh pr list --base develop --state merged --limit 50 --json number,title,mergedAt,closingIssuesReferences
# write /tmp/release.md: body per gitgud-pr section 4, an Included list (- #12 watchdog: no error lines before first loot), one Closes #N line per issue
for n in $(git log --no-merges --format=%s origin/main..origin/develop | grep -oE '\(#[0-9]+\)$' | tr -d '(#)'); do # squash-merged PRs in this release
gh pr view "$n" --json number,title,body,files --jq '"#\(.number) \(.title)\(if ((.body // "") | test("\\*\\*Changes checks\\*\\*")) or ([.files[].path | test("^\\.github/|^\\.claude/|(^|/)(CODEOWNERS|CLAUDE\\.md|AGENTS\\.md|SKILL\\.md|review-gate\\.yml)$")] | any) then " [changes checks]" else "" end)"' || echo "#$n lookup failed: check by hand"
done # the body section is the source; the path test is a backstop that sees only the first 100 files
git log --no-merges --format='%h %s' origin/main..origin/develop | grep -vE '\(#[0-9]+\)$' # commits without a PR number: check by hand
# write /tmp/release.md: body per gitgud-pr section 4, an Included list (- #12 watchdog: no error lines before first loot), a Changes checks list of the PRs marked [changes checks], one Closes #N line per issue
gh pr create --base main --head develop --title "release: <summary>" --body-file /tmp/release.md
sha=$(gh pr view <N> --json headRefOid -q .headRefOid) # show it with the body: the go covers exactly this commit
gh repo view --json deleteBranchOnMerge -q .deleteBranchOnMerge # true would delete develop on merge: stop and ask
gh pr checks <N> --watch --fail-fast && gh pr merge <N> --merge --match-head-commit "$sha" # merge commit; never squash, never --delete-branch (it would delete develop)
[ "$(gh pr view <N> --json state -q .state)" = MERGED ] && for n in $(gh pr view <N> --json body -q .body | grep -ioE '^[-*+ ]*(close[sd]?|fix(e[sd])?|resolve[sd]?):? #[0-9]+' | grep -oE '[0-9]+$'); do gh issue edit "$n" --remove-label "status: in progress,status: in review,status: blocked,status: ready for release"; done # after the merge (also a later manual one); issues from the merged PR body's closing lines; skip if the repo has no status labels (the edit fails)
```

Then tag from `main` and merge `main` back into `develop` with `gitgud-release`. No checks on the release PR: ask the user before merging.
Expand Down
Loading