Gas City pack: the Forgejo forge, opens pull requests and follows them to merge
This repository has been archived on 2026-11-20. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Go 97.4%
  • Shell 2.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mikhail Lukianchenko b5fd9bf31b
All checks were successful
Release / test (push) Successful in 15s
Release / ci (push) Successful in 0s
Release / release (push) Successful in 0s
Release / changelog (push) Successful in 4s
Release / plan (push) Successful in 4s
Release 0.3.0: merge-ready waits for every requested reviewer (#5)
Forgejo drops a REQUEST_REVIEW entry once its reviewer reviews, so the rule reads requested_reviewers and REQUEST_REVIEW entries, then each reviewer's latest verdict.
Team requests are not resolved to members; any pending one blocks.

Reviewed-on: #5
2026-11-20 17:28:37 +00:00
.forgejo/workflows Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
assets/scripts Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
bin Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
cmd Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
doctor/build Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
internal Release 0.3.0: merge-ready waits for every requested reviewer (#5) 2026-11-20 17:28:37 +00:00
orders Release 0.2.0: rework sends pull request feedback back to its bead (#4) 2026-11-18 21:45:52 +00:00
.gitignore The merge order: merge-ready and its rig and city orders (#1) 2026-11-17 13:23:07 +00:00
CHANGELOG.md Release 0.3.0: merge-ready waits for every requested reviewer (#5) 2026-11-20 17:28:37 +00:00
go.mod The merge order: merge-ready and its rig and city orders (#1) 2026-11-17 13:23:07 +00:00
pack.toml The merge order: merge-ready and its rig and city orders (#1) 2026-11-17 13:23:07 +00:00
README.md Release 0.3.0: merge-ready waits for every requested reviewer (#5) 2026-11-20 17:28:37 +00:00

gascity-forgejo-pack

A Gas City pack that merges approved Forgejo pull requests and sends pull requests with feedback back to their beads. The merge-ready and rework commands act on the repository named by the origin remote of their working directory.

Installation

The merge-ready and rework commands are built from the pack's source on first use and by gc doctor --fix; the build doctor check reports whether they are built. The machine that runs the city's orders and runtime needs go and access to the Go module proxy. The binary is cached per version of the pack's Go code under ${GC_PACK_BUILD_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/gascity-packs}/forgejo/.

Import the pack for each rig in city.toml:

[[rigs]]
name = "my-rig"
path = "../my-rig"

[rigs.imports.forgejo]
source = "https://sarak.sh/mikluko/gascity-forgejo-pack.git"
version = "^0.1"

Each rig import registers that rig's orders. The city orders are promoted once from the rig imports, so no separate city-level import is needed.

Each order runs its command from bin/ every minute after a cooldown:

Order Command Scope Working directory
merge-ready merge-ready One per importing rig Rig root
merge-ready-city merge-ready City City root
rework rework One per importing rig Rig root
rework-city rework City City root

The city orders are for a city whose own repository is not one of its rigs. Each working directory must have an HTTPS or SSH origin naming its Forgejo repository.

Credentials

Set FORGEJO_TOKEN to supply a bearer token directly. Otherwise the command runs git credential fill for the origin's HTTPS URL on every run, with terminal and askpass prompts disabled. Git's credential.useHttpPath setting is honoured. Configure any credential helper through git; the pack does not select or configure one.

merge-ready needs a token with push permission on the repository; rework only reads, so read access is enough. Credentials are never cached or logged.

Merge gates

Every open pull request is read again before any gate is evaluated. It is squash-merged only when:

  1. The repository reports permissions.push.
  2. The pull request is open, unmerged and mergeable.
  3. Its base branch is protected, requires at least one approval and reports user_can_merge.
  4. Its exact head has a successful combined status. If the base does not require status checks, a head with no statuses passes; a head with statuses must still be successful.
  5. A review approves that exact head and is official, current, non-stale and non-dismissed.
  6. Every requested reviewer's latest undismissed APPROVED or REQUEST_CHANGES review approves that exact head and is non-stale; it need not be official. A requested reviewer is a user in the pull request's requested_reviewers or with a review in the REQUEST_REVIEW state. One who has not reviewed, or whose latest verdict requests changes or approves an older commit, holds the merge. A pending team review request holds it too; team members are not resolved.

The merge request pins the checked head. HTTP 409 leaves a moved head for the next run. A 200 response is confirmed by reading the pull request again and requiring merged. Errors and missing fields leave the pull request open.

The command writes one decision line per pull request. It exits non-zero only when the repository or its open pull request list cannot be read.

Rework

rework hands a pull request's feedback back to the bead it was opened for. A pull request is tied to a bead when its head branch name is the id of a bead in the beads store of the working directory; bd runs there, from PATH. For each open pull request:

  1. bd show <branch> --json reads the bead. A pull request whose branch names no bead is skipped, and so is one whose bead is not closed: it is already being worked or parked.
  2. Feedback is collected for the current head commit only. It is the failed statuses (context, description and target URL) when the head's combined status is failure or error, and each official REQUEST_CHANGES review of that exact head that is current, non-stale and non-dismissed, with its body and inline comments. A review or status on an older commit counts for nothing: a new push answers it.
  3. When there is feedback, bd reopen reopens the bead and bd update clears its assignee and appends notes. The notes start with the pull request's URL and the head commit, then list the failed checks and the review.

The bead is open after that, so later runs leave it alone until it is closed again. The command writes one decision line per pull request and exits non-zero only when the repository or its open pull request list cannot be read; a failing bd or API call is reported on that pull request's line. It never writes to Forgejo.

Development

go vet ./...
go test -race ./...
GOMAXPROCS=1 go test -count=20 ./...
gc lint .

The tests use a local fake Forgejo API and temporary git credential helpers; they do not need a live server.

Releases

Record a notable pull request change under [Unreleased] in CHANGELOG.md.

A release pull request turns those notes into a dated semantic version section. After it merges, the release workflow runs CI, tags the commit vX.Y.Z and creates the Forgejo release.