You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolve spec/audit.py's Hub Name Lazily So Importing Scripts Parse Arguments Before Any Read #2829
CODESTYLE.md General "Command-Line Arguments", which arrives with #2285, says a command-line script refuses an unrecognized argument with a non-zero exit before any read or write. spec/audit.py resolves its hub name when imported, at module level (HUB_NAME, HUB_NAME_FROM_REMOTE = hub_name()), and hub_name() runs git config --get remote.origin.url. So a script importing spec/audit.py at the top runs that read before argparse ever sees its arguments, --help and an unknown flag included.
The #2285 gate showed this when git was briefly added to its recording stubs. canonical_review.py, spec/audit.py, spec/fidelity_honesty.py, and spec/workflow_reuse.py were the scripts it named. Other scripts also import the module, so the fix should check them all rather than only those four.
Repro
Put a recording git stub first on PATH and run python3 spec/audit.py --bogus-flag from a hub checkout. The stub records a config --get remote.origin.url call before the usage error prints.
Proposed fix
Resolve the hub name lazily, for example with a cached accessor that runs on first use, and replace the module constant's uses with it. Then add git to the commands that tests/test_cli_usage.py records in RECORDED. It is left out today because this read would fail the gate, and adding it means the gate holds every entry point to "before any read" as well.
Context
Found while gating #2285 on feature/auto-2285. The maintainer chose to track it here rather than fix it in that pull request, because the constant has many uses and the change is wider than that pull request's scope.
Activity
Require Every CLI Script to Answer Help and Refuse Unknown Arguments (#…
Resolve the Audit Hub Name Lazily (#2926)
Count No Earlier Round When the Head Is Unreadable and Import Audit a…