mirror of
https://github.com/Monkopedia/rouse-context.git
synced 2026-11-29 11:13:05 +00:00
Correct the gate-filters usage example to the shape the gates actually use
Review of #697 found the header documenting a calling convention that both of its own call sites abandon in the same PR: the usage example ends the pipeline in `|| true` and resolves the library via `$(git rev-parse --show-toplevel)`, while the two converted gates use a `set +e` bracket and `${BASH_SOURCE[0]}`. A shared library asserting a false property about itself is the exact failure this file exists to end, and it lands on the author most likely to copy it. Measured both ways with the reviewer's method -- transcribe the example verbatim into a gate, add it to the tracked set, and run the phase-1 invocation `check-shell-lint.sh` uses (shellcheck 0.11.0, `-o check-extra-masked-returns,check-set-e-suppressed`) over all tracked `*.sh`: old example: 3 findings, exit 1 SC2312 on `source "$(git rev-parse --show-toplevel)/..."` SC2310 x2 on the two library functions in the `|| true` pipeline new example: 0 findings, exit 0 -- and the probe gate also RUNS clean against the real tree So the documented example now passes the repo's own shell gate as written, which is the property the previous one silently lacked. The trailing paragraph that claimed "the caller keeps the `|| true` on the pipeline as a whole exactly as before" is corrected too: the status must still be discarded, and the reason for the `set +e` form over `|| true` is SC2310, not taste. Both details are now stated as deliberate, with the reason attached, rather than left to be re-derived. Comment-only. `gate-filters-test.sh` (20 ok:), both converted gates' self-tests and both gates on the real tree are unchanged and green.
This commit is contained in:
parent
ec5fee37c5
commit
c45035b4e5
1 changed files with 29 additions and 7 deletions
|
|
@ -1,13 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
# Shared post-filters for this repo's grep-based CI gates (#597).
|
||||
#
|
||||
# Sourced, not executed:
|
||||
# Sourced, not executed. This example is the shape the two converted gates
|
||||
# actually use, and it passes `scripts/check-shell-lint.sh` phase 1 as written --
|
||||
# both of which matter, because the next gate will be a copy of one of those two
|
||||
# and of this block:
|
||||
#
|
||||
# source "$(git rev-parse --show-toplevel)/scripts/lib/gate-filters.sh"
|
||||
# gate_lib_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# # shellcheck source=scripts/lib/gate-filters.sh
|
||||
# source "$gate_lib_dir/lib/gate-filters.sh"
|
||||
#
|
||||
# set +e
|
||||
# hits=$(git grep -nE "$pattern" -- "${paths[@]}" \
|
||||
# | skip_comment_continuations \
|
||||
# | exempt_path AuditDetailScreen.kt \
|
||||
# || true)
|
||||
# | exempt_path AuditDetailScreen.kt)
|
||||
# set -e
|
||||
#
|
||||
# Two details are deliberate rather than incidental.
|
||||
#
|
||||
# The library is resolved from the GATE's own location, not from the working
|
||||
# directory: `$(git rev-parse --show-toplevel)` reads the enclosing repo, which
|
||||
# is the wrong repo when the gate is invoked from the throwaway tree its
|
||||
# self-test builds, and shellcheck flags the discarded status besides (SC2312).
|
||||
#
|
||||
# The pipeline sits inside a `set +e` bracket rather than ending in `|| true`.
|
||||
# Both discard the status, and the status must be discarded -- see below -- but
|
||||
# a FUNCTION in an `||` condition turns `set -e` off inside it, which
|
||||
# `check-shell-lint.sh` reports as SC2310 and fails the build over.
|
||||
#
|
||||
# =============================================================================
|
||||
# READ THIS FIRST IF YOU ARE ADDING A GATE
|
||||
|
|
@ -55,9 +74,12 @@
|
|||
# `check-apk-distribution.sh` have none and deliberately do not source this file.
|
||||
#
|
||||
# Both functions read stdin and write stdout, so they compose as pipeline
|
||||
# stages. Neither swallows `grep`'s exit status: `grep -v` exits 1 when it emits
|
||||
# nothing, which for a gate is the GOOD case, so the caller keeps the `|| true`
|
||||
# on the pipeline as a whole exactly as before.
|
||||
# stages. Neither swallows `grep`'s exit status, so the CALLER must discard it:
|
||||
# `grep -v` exits 1 when it emits nothing, which for a gate is the GOOD case,
|
||||
# and under `set -euo pipefail` that would otherwise kill the gate on a clean
|
||||
# tree. Both converted gates do that with the `set +e` bracket shown above --
|
||||
# which is a change from the `|| true` they carried before this library existed,
|
||||
# and the reason is SC2310, not taste.
|
||||
|
||||
# Drop lines whose CONTENT field is a block-comment continuation (` * ...`), so
|
||||
# prose about the banned construct -- a KDoc paragraph, a pattern list written
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue