Repository navigation
setup.sh is a shim over setup-project.py: the flow exists once (#50) - #60
Conversation
The bash entry point keeps exactly three jobs - find a Python 3.9+ (python3, then python), clone the standard into a temporary directory when it is not already inside a checkout, and tell the Python where the person was standing (--into first, so the #39 property holds) - and hands everything else to setup-project.py. Developer path: exec with NO cd, because the Python reads origin from the invocation directory. Self-bootstrap: the (0) block byte for byte, -- before the repository argument, --shape-ref and --keep-shape-checkout scanned but never consumed, the trap owns the temp checkout. New handshake OPENREPOSHAPE_SELF_BOOTSTRAP=1: a shim-cloned checkout is a real checkout, so without it the Python would detect the organisation from whatever repository the person stood in; with it, --org is required, one wording, after the clone. ${BASH_SOURCE[0]:-$0} removes the unbound-variable line the old file leaked under curl | bash. Bash 3.2 clean for the tests-macos job. Two assertion edits in test_setup_sh.py (the running interpreter, one usage banner); the flag-parity test retired for a test that setup.sh parses no flags of its own. 575 tests. Lane: xfactory-2 (xFactory-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
# Conflicts: # tests/test_repo_hygiene.py
…ol-character and ref-rule guards, exec from the proven toplevel (#50) Adversarial review before opening, all in the one surface the shim still owns: the shim probes git itself before any clone (a missing git looked like not-a-checkout and died at git clone with 127 where the Python prints the house refusal); OPENREPOSHAPE_REPO refuses control characters as well as a leading -, without echoing the value; --shape-ref mirrors the Python REF_RE (alphanumeric start, no .., no .lock, the ref alphabet); the developer exec runs setup-project.py from the git toplevel the guard proved, not from $SCRIPT_DIR, so bash -s from a subdirectory of a checkout works; the handshake variable is unset before that exec so a leaked value cannot misdescribe a fork; README, AGENTS.md and the openRepoShape command say scripts/bootstrap.py and setup-project.py where they said make bootstrap and setup.sh --help; both scan false positives named. Three bash-side tests for the guards, offline. 591 tests. Lane: xfactory-2 (xFactory-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 15 hours and 54 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's Guidesetup.sh is consolidated into a small, Bash 3.2-compatible front end that validates prerequisites, performs only the required self-bootstrap checkout work, preserves the caller’s directory and arguments, and hands the complete flow to setup-project.py; the Python entry point now owns the single parser and behavior, with a handshake preventing unsafe organisation detection and expanded tests/docs covering the delegation. Sequence diagram for setup.sh delegation and self-bootstrapsequenceDiagram
participant User
participant Shim as setup.sh
participant Git
participant Python as setup-project.py
participant Flow as Project flow
User->>Shim: Invoke with arguments
Shim->>Shim: find_python()
Shim->>Git: Check git and detect checkout
alt Existing openRepoShape checkout
Shim->>Python: exec with --into and original arguments
else No checkout
Shim->>Git: clone --depth 1 ... -- repository
Shim->>Git: checkout --shape-ref
Shim->>Python: run with --into and OPENREPOSHAPE_SELF_BOOTSTRAP=1
Python->>Python: Require --org
end
Python->>Flow: Parse flags and run preflight
Flow->>Flow: Scaffold, clone, and run scripts/bootstrap.py
Shim-->>User: Preserve child status and clean temporary checkout
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
🟡 Changes recommended
The shim’s --shape-ref validation is missing the Python flow’s 255-character limit, so an unbounded ref can still reach git checkout before Python parsing/validation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR consolidates the project-creation “front door” so setup-project.py is the single source of truth for the setup flow, while setup.sh becomes a minimal Bash 3.2-compatible shim that bootstraps (when needed) and delegates to the Python implementation.
Changes:
- Replaced the former ~500-line
setup.shimplementation with a delegation shim (Python discovery, git presence check, self-bootstrap clone,--intoinjection, and the self-bootstrap--orghandshake). - Updated tests to reflect the unified Python-owned preflight/usage output and added shim-focused coverage (guards + handshake behavior).
- Refreshed docs and command help text to describe
setup.shas a shim andsetup-project.pyas the flow, and to reflect bootstrap running viascripts/bootstrap.py.
File summaries
| File | Description |
|---|---|
setup.sh |
Replaced full flow with a Bash shim that finds Python, self-bootstraps a checkout when needed, and hands off to setup-project.py (incl. OPENREPOSHAPE_SELF_BOOTSTRAP handshake). |
setup-project.py |
Centralizes wording/behavior as the canonical flow; adds shared ORG_REQUIRED refusal used by both direct self-bootstrap and shim handover. |
openRepoShape |
Updates usage/help text to refer to setup-project.py options and clarifies that ./setup.sh --help prints the Python usage. |
README.md |
Updates “What setup.sh does” and related sections to describe shim delegation and bootstrap via scripts/bootstrap.py. |
AGENTS.md |
Updates bootstrap references from make bootstrap to scripts/bootstrap.py (what make bootstrap runs). |
tests/test_setup_sh.py |
Adjusts assertions for Python-owned output and adds shim-guard tests (hostile repo env, invalid --shape-ref, missing git). |
tests/test_setup_project_py.py |
Replaces the old flag-parity test with tests asserting setup.sh remains a shim and that self-bootstrap wording stays aligned. |
tests/test_openreposhape_command.py |
Updates expected usage line to match the new delegation model. |
tests/conftest.py |
Updates Windows skip rationale to match the new interpreter-probing shim behavior. |
tests/test_repo_hygiene.py |
Updates README line-count cap with rationale reflecting the shim documentation additions. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Mirrors `setup-project.py`'s REF_RE: a ref starts with a letter or digit, | ||
| # holds only letters, digits, '.', '_', '/', '-', is never a `..` range and | ||
| # never ends in `.lock` (git's own lock-file name for one). Only reached when | ||
| # $SHAPE_REF is non-empty — every alternative below requires at least one | ||
| # character to match. | ||
| case "$SHAPE_REF" in | ||
| [!A-Za-z0-9]*|*..*|*.lock|*[!A-Za-z0-9._/-]*) die "--shape-ref is '$SHAPE_REF', which is not a branch, tag or commit this tool will pass to \`git checkout\`: a ref starts with a letter or digit, uses only letters, digits, '.', '_', '/', '-', has no '..' and does not end in '.lock'." ;; | ||
| esac |
…tes, the shim's --shape-ref length bound (#63) (#65) * Empty $OPENREPOSHAPE_REPO means unset, the standard's own .gitattributes, the shim's --shape-ref length bound (#63) Three Copilot inline comments read after their PRs merged (#56, #58, #60) and deferred as cosmetic. None changes what a user sees today; each left a statement in the tree that was not true, or a bound present in one entry point and absent from the other. setup-project.py: the comment above the $OPENREPOSHAPE_REPO read claimed that checked_value refuses an empty value; the truthiness test in front of it means an empty value is never checked and falls to DEFAULT_SHAPE_REPO, exactly as setup.sh's ${OPENREPOSHAPE_REPO:-<default>} does. Ruled on #63: empty means unset in both entry points. Behaviour unchanged; the comment now says so. One test per entry point pins it offline by handing the child a url.<file-uri>.insteadOf <default> rewrite through GIT_CONFIG_COUNT, so the echoed clone line naming the default URL proves the empty value fell through. .gitattributes at the root: the templates got theirs in #51; the checkout that ships them had none, so a core.autocrlf=true clone of openRepoShape itself turned every LF into CRLF and unname_everywhere() in the update-shape-add tests, which matches a copy-list line whole, stripped nothing. Same rule, * text=auto eol=lf, its own header; git add --renormalize is a no-op because every tracked file is already LF. Hygiene tests pin the rule and its agreement with both templates; the helper matches \r?\n anyway, for a checkout made before this landed. setup.sh: the --shape-ref case mirrored REF_RE's alphabet but not its 255 character bound, so an over-long ref reached git checkout in the temporary clone. A length check after the case refuses it, naming the length rather than echoing the value. bash 3.2 clean. A 256-character ref joins both parametrised refusal tests; a dedicated shim test asserts the refusal names --shape-ref and 255, exits 2 and does not echo the value. 611 -> 619 tests. Lane: xfactory-2 (xFactory-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * PR #65 review: the shim refuses an over-long or control-character --shape-ref before anything echoes it (#63) Copilot on PR #65: the shape `case` echoed the raw --shape-ref in its refusal, so a value holding a newline could forge a line onto stderr, and an over-long ref that also failed the shape was echoed as 255+ characters of noise. Three checks now run in order - length, then a control character, both refusing without naming the value the way the OPENREPOSHAPE_REPO guard above them does, then the shape case, which by then only ever sees a printable ref of at most 255 characters. Two tests: a newline-carrying ref is refused and the forged line never reaches stderr; the over-long test is parametrised over a legal shape and an illegal one, and neither is echoed. Also from the review: the comment claiming the case is "only reached when non-empty" (it runs unconditionally and matches nothing) is reworded, and the hygiene test named "repositorys" is renamed. Lane: xfactory-2 (xFactory-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>



Lane: xfactory-2 (xFactory-2)
Claim: #50 (comment)
Closes #50.
What this changes
setup.shis now a shim oversetup-project.py, so the start-a-project flow exists once. Brett Heap, 2026-09-05: "pick up #50 and #51 too". #53 kept the 500-line bash intact on purpose and held the two entry points together with a flag-parity test; this is the consolidation it deferred, as its own PR so a bisect points at the delegation and not at Windows support.The shim keeps exactly three jobs. It finds a Python 3.9 or newer (
python3, thenpython, each probed with the interpreter's ownsys.version_info) before anything else. When it is not already inside a checkout of the standard it clones one into a temporary directory, exactly as the old section (0) did — the(0) self-bootstrapblock byte for byte,--depth 1under the same rule,--shape-refhonoured,--before the repository argument, the cleanup trap owning the directory and--keep-shape-checkoutkeeping it. And it tells the Python where the person was standing:--into <invocation dir>injected FIRST so an explicit--intostill wins (the #39 property). Everything else — preflight, organisation, names, plan, the oneyes, scaffold, clone, bootstrap, hand-over — issetup-project.py's. From a checkout itexecs the Python with nocd, because the Python readsoriginfrom the invocation directory.One new handshake, and it is a safety fix. A shim-cloned checkout is a real checkout, so the Python would take the developer path and DETECT the organisation from whatever repository the person happened to be standing in — a
curl | bashrun started inside~/work/acme-websitewould scaffold three repositories intoacme. The shim setsOPENREPOSHAPE_SELF_BOOTSTRAP=1on the hand-over command only, and the Python then requires--org, with the same sentenceself_bootstrap()already uses, before the preflight.Also fixed while here: the old file leaked
bash: line 36: BASH_SOURCE[0]: unbound variableundercat setup.sh | bash -s --; the shim writes${BASH_SOURCE[0]:-$0}. The shim is written to bash 3.2 rules for thetests-macosjob that #57 added:${1+"$@"}everywhere, no associative arrays, nomapfile, no${var,,},mktemp -dwith an explicit template.What a human will notice, stated because the acceptance asks
[ok]/[!!](pure-ASCII Python) where bash printed✓/✗.makeis neither probed nor used; bootstrap runs aspython3 scripts/bootstrap.py, which is whatmake bootstrapran.git, one refusal each, before anything else; the old preflight reported every missing prerequisite in one pass. Everything else is still reported together by the Python's preflight.--helpfromcurl | bashclones the standard before printing usage, because the banner is the Python's; from a checkout nothing changes.${2:?}exited 1. One parser now; the divergence A native Windows path: setup-project.py, a windows-latest job, and the README route (#49) #53's review recorded is resolved, not tolerated.scaffold-project.py,git clone,bootstrap.py) prints aREFUSED:line naming it, whereset -eexited silently.Adversarial Opus review before opening, folded in
The reviewer confirmed the shim, the trap and the handshake and found the gaps in the one surface the shim still owns, section 0: no
gitprobe before the clone (git: command not found, exit 127, where the Python prints the house refusal);OPENREPOSHAPE_REPOguarded only for a leading-, so a control character could print a forgedREFUSED:line;--shape-refguarded only for-, soa..bortopic.lockreachedgit checkoutwith git's own error; the exec used the script directory where the guard had proven the git toplevel, which brokebash -sfrom a subdirectory of a checkout; a leakedOPENREPOSHAPE_SELF_BOOTSTRAPmisdescribing a fork checkout (now unset before the developer exec); and four docs left sayingmake bootstraporsetup.sh --help. All fixed, each guard with a bash-side test, all offline (three new tests; 585 → 591).Tests
tests/test_setup_sh.py: exactly two assertion edits, each with its comment — the preflight line now matches the RUNNING interpreter (python 3.x.y (path)) instead of the literalpython3(which passed by accident off thebootstrap runs asline), and the usage banner isusage: setup-project.py(one banner, printed by the one implementation, invoked under two names). One fixture change, not an assertion:test_self_bootstrap_without_org_refusessetsOPENREPOSHAPE_REPOto this checkout, because the refusal now fires after the clone and the test must stay offline. The flag-parity test is retired — it parsed a usage heredoc the shim does not have and would have errored, and parity of two lists is moot when there is one — and replaced bytest_setup_sh_parses_no_flags_of_its_own(the shim may name only the six flags about the checkout it makes) andtest_the_two_entry_points_say_self_bootstrap_the_same_way.test_the_shim_handshake_requires_an_orgruns from a fork directory and was proven red without the handshake.Every other test in the bash suite now exercises the shim's pass-through end to end. README § "What setup.sh does" says what the shim is and shows the commands the Python runs; the cap moves 945 → 948.
Evidence
python3 -m pytest tests -q→ 591 passed (main at1a706dc: 582). All three CI jobs on this PR — thetests-macosjob is the shim's first real bash 3.2 run. Adversarial Opus review before opening.Merge word: Brett Heap, 2026-09-05, "merge #50 and #51 on green too".
🤖 Generated with Claude Code
Summary by Sourcery
Make setup-project.py the single project-creation flow and reduce setup.sh to a safe cross-platform delegation shim.
Bug Fixes:
Enhancements:
CI:
Documentation:
Tests: