Skip to content

Commit 4ed44eb

Browse files
docs(release): use the built binary where the audit's exit code matters
The README said `go run` forwards the audit's exit code. It does not: any non-zero exit of the program comes back as go run's own 1, after an "exit status N" line on stderr. An audit that could not be completed exits 2 precisely so a gate can tell "no answer" from "outstanding work", and under go run the two look identical -- `--limit 0` exits 2 from the binary and 1 from go run. Show the exit-code example with the built binary, branching on all three codes, and say that go run is fine for reading the report but not for anything that acts on the exit status. /backport-audit is already in .gitignore, so building it at the repository root leaves nothing to commit by accident. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent a6c3772 commit 4ed44eb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎cmd/backport-audit/README.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ Arguments and flags may be given in any order.
4242
`0` when nothing is outstanding, `1` when something is, `2` when the audit could not be completed. That is the point of the tool, so it holds in `--json` mode too:
4343

4444
```bash
45-
go run ./cmd/backport-audit release-1.5 || echo "do not cut yet"
45+
go build ./cmd/backport-audit
46+
./backport-audit release-1.5
47+
case $? in
48+
0) echo "clean" ;;
49+
1) echo "do not cut yet" ;;
50+
*) echo "the audit itself failed; no answer yet" ;;
51+
esac
4652
```
4753

48-
`go run` forwards the exit code but also prints its own `exit status 1` line to stderr. Build the binary first (`go build ./cmd/backport-audit`) where that noise is unwelcome.
54+
Use the built binary (`go build` as above, or `go install ./cmd/backport-audit`) wherever the exit code matters. `go run` does not preserve it: any non-zero exit of the program comes back as `go run`'s own `1`, after an `exit status N` line on stderr, so under `go run` an audit that could not be completed looks exactly like one that found outstanding work. `go run` is fine for reading the report.
4955

5056
Exit `2` covers the cases where an answer cannot be trusted rather than merely being bad news, and a saturated listing is one of them: `gh` truncates at `--limit` in silence, and a truncated list does not make the audit partial, it makes it wrong — the PRs past the cut are reported nowhere and the exit code says clean. Each of the three listings is checked against its cap and fails instead, naming the cap to raise. The label listings go through GitHub search, which never returns more than 1000 results however far it is paginated, so they are checked against the lower of `--limit` and 1000: a `--limit` above 1000 cannot make a listing cut at 1000 pass for complete.
5157

0 commit comments

Comments
 (0)