FORGEJO_TOKEN_COMMAND in the forgejo pack; gc forgejo token; the doctor; the formula; the Worker's prompt line #90
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!90
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-vupm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
FORGEJO_TOKEN_COMMANDto the forgejo pack, so a city can keep its token in a secret store without the pack knowing which, andgc forgejo token, so the Reviewer's formula and the tool read the token from the one place.What changed
readToken(newtoken.go): whenFORGEJO_TOKEN_COMMANDis set it runs it withsh -cand the trimmed stdout is the token; it wins overFORGEJO_TOKEN_FILE, and a failing or empty command is an error, with no fall back to the file. The error carries the command's stderr cut to 300 bytes and never its stdout. Every reader (pr open|state|merge|review|commentand the four orders) goes through it.gc forgejo tokenprints the token asreadTokenreads it. The formulamol-forgejo-reviewcalls it in the six places it did$(cat "$FORGEJO_TOKEN_FILE").gc forgejo pr ....prhelp texts, thetokenhelp, and a changelog fragment.Not in this pull request: the city's own change (
workspace.env, the three[[orders.overrides]], the Reviewer's patch, and the import range), which waits for the release. Note for it: the command wins over the file wherever each is set, so a city whose workspace sets the command must set the command in the Reviewer's patch too (README, "Where the token comes from"). Each fetch of a pull request in an order runs the command once, so an order that looks at N pull requests starts it N times.Checks run:
go vet ./...,go test ./...,gc lint .,tests/{formula,reviewer,doctor,operator-overlay,researcher,researcher-formula,pack-cache,merge,handover,failures,waiting,apply,upgrade,worktree-setup,worktree,gnu-tools}.sh, the shell budget test (0 findings) andchangelog -base main, all passing on the head.Tests fail without the change: I undid each in the worktree and saw it fail, then restored it.
token_test.go: withreadTokenignoring the command, four tests fail; with the stderr bound removed, the bounded-stderr case fails; with an empty output accepted, the no-token case fails.tests/doctor.shfails against the old doctor,tests/reviewer.shagainst the old formula, and the new lines oftests/formula.shwithout the prompt line. Not checked that way: the-u FORGEJO_TOKEN_COMMANDadded totests/merge.shandtests/pack-cache.sh, which only keeps a session's own variable out of those runs.Bead: gascitypacks-vupm
Review of
06f117b8e4for gascitypacks-vupm. Checks of the head: success.Verdict
pass
Findings
upgrade,scheduleandcheckssections still say the order needsFORGEJO_TOKEN_FILE(and thescheduleexample at :276 only shows the file). The general sentence at :22 and the new "Where the token comes from" section cover the command, so nothing is wrong in practice, but a reader of one section alone is told the file is required. To fix: say "the token (FORGEJO_TOKEN_COMMANDorFORGEJO_TOKEN_FILE)" there, as :420 and :586 already do.$GC_PACK_DIR(README.md:27, token help). A command with a relative path can pass the doctor and fail in the tool, or the other way round. The README already says to use absolute paths. To fix:cd "$GC_PACK_DIR"before thesh -cwhen that variable is set, or say in the doctor's comment that the directory differs.gc forgejo tokenandgc forgejo pr, but the README lets a rig bind the forge pack under another name (formula_vars = { forge = "<name>" }). For the city's binding this is right. A rig with another binding would get a prompt that names the wrong command.msg[:maxCommandStderr]cuts at a byte, so a multi-byte character in the stderr can be split. This only affects how the error looks. Not worth a change unless it is touched again.Verified
readTokenrunsFORGEJO_TOKEN_COMMANDwithsh -c, and the command wins over the file with no fall back. A failing command's stderr is cut to 300 bytes and its stdout is left out.readToken(ctx, e):fetchPull,clientForWorktree,prMerge,prReviewandscheduler.target.gc forgejo token, with its help and a 2-line run.sh stub.$(cat "$FORGEJO_TOKEN_FILE")lines ofmol-forgejo-revieware now$(gc {{forge}} token).tests/reviewer.shpins that everycurlcarries it and that nothing else reads where the token comes from, and its stub curl refuses any other token.176c520), with no conflict. The forge reportsmergeable.env -i, proved to be 0); all passed:go vet ./...go test -count=1 ./...go test -race ./forgejo/...gc lint .(2 packs ok)tests/*.shthat CI runs,tests/doctor.shincluded: formula, reviewer, doctor, operator-overlay, researcher, researcher-formula, pack-cache, merge, handover, failures, waiting, apply, upgrade, worktree-setup, worktree, gnu-tools, view-beads, view-mail, permission-deny, permission-requestchangelog -base main(exit 0)go test -v -run TestShellBudget ./internal/budget): 32 units, 10 in the ledger, 0 findings. The doctor's growth stays under the threshold.