Repository navigation
setup-project.py: Copilot's five post-merge findings on #53 (#55) - #56
Conversation
The docstring now promises ASCII for the SOURCE and the fixed markers this file writes, not for echoed values or child output; --help says what --into defaults to in self-bootstrap mode; OPENREPOSHAPE_REPO is checked (empty, leading -, control characters refused, the variable named) and the shape clone carries -- before the repository argument; PYTHON_CMD is the platform-conventional command, matching repo_shape.PYTHON, so a remediation names something the reader can type; _main() uses the GIT_MISSING and PREREQ_MISSING constants. Three tests. 573 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 16 hours and 28 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 GuideThe PR applies five post-merge fixes in setup-project.py: it tightens documentation and output encoding semantics, validates and defensively passes OPENREPOSHAPE_REPO to git, makes displayed Python commands retypable across platforms, corrects self-bootstrap help, and deduplicates preflight strings, with tests covering the new repository and platform behaviors. Sequence diagram for validated self-bootstrap repository cloningsequenceDiagram
participant User
participant SetupProject as setup-project.py
participant Git
User->>SetupProject: self_bootstrap(opts, original_argv, invocation_dir)
SetupProject->>SetupProject: checked_value(OPENREPOSHAPE_REPO, raw_shape_repo, PATH_RE)
alt repository value accepted
SetupProject->>Git: git clone -- shape_repo checkout
Git-->>SetupProject: clone result
else repository value rejected
SetupProject-->>User: named validation error
end
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
$OPENREPOSHAPE_REPO set to an explicitly empty string currently bypasses the intended empty-value refusal due to a truthiness check, and the test suite doesn’t cover this case.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses follow-up hardening and documentation correctness in setup-project.py (post-merge findings from #53/#55), focusing on safer self-bootstrap behavior and ensuring user-facing guidance remains platform-correct while keeping output stable.
Changes:
- Tighten and clarify the module docstring’s ASCII guarantees and output encoding behavior.
- Improve
--helptext for--intoto reflect the effective default in self-bootstrap mode. - Harden self-bootstrap cloning by validating
$OPENREPOSHAPE_REPOand adding--before the repository argument; also reuse existing prerequisite error message constants. - Extend tests for platform-specific bootstrap messaging and self-bootstrap clone argument guarding.
File summaries
| File | Description |
|---|---|
| setup-project.py | Clarifies ASCII/encoding guarantees, updates help text, validates/guards $OPENREPOSHAPE_REPO for git clone, and deduplicates prerequisite messages. |
| tests/test_setup_project_py.py | Adds coverage for platform-specific bootstrap messaging and self-bootstrap clone argument guarding with $OPENREPOSHAPE_REPO. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| raw_shape_repo = os.environ.get("OPENREPOSHAPE_REPO") | ||
| shape_repo = (checked_value("OPENREPOSHAPE_REPO", raw_shape_repo, PATH_RE) | ||
| if raw_shape_repo else DEFAULT_SHAPE_REPO) |
| def test_a_hostile_openreposhape_repo_refuses(tmp_path): | ||
| """`OPENREPOSHAPE_REPO` reaches `git clone` as the repository argument, | ||
| which is exactly the argument git itself will never refuse for us: a | ||
| leading `-` there is an OPTION to git, not a name. `-c core.x=y` is the | ||
| shape of a value that would turn the clone into a config injection, and | ||
| it is refused before `git` ever sees it - by the same `checked_value` | ||
| rule as every flag on the command line - naming the environment | ||
| variable so the person fixing this knows what to change.""" | ||
| outside = make_outside_checkout(tmp_path) | ||
| result = run_entry("--org", "demoorg", "--project", "Sample", "--yes", | ||
| "--local-remote-dir", str(tmp_path / "remotes"), | ||
| cwd=outside, script=outside / "setup-project.py", | ||
| extra_env={"OPENREPOSHAPE_REPO": "-c core.x=y"}) | ||
| assert result.returncode == 2 | ||
| assert "OPENREPOSHAPE_REPO" in result.stderr | ||
| assert not (tmp_path / "remotes").exists() |
…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: #55 (claim in the issue body)
Closes #55.
Copilot left six inline comments on #53 across three review rounds; the last round landed after the final push and the PR merged on the standing "merge on green" word before it was read. One was already fixed in
acd460b(--shape-refvalidated). These are the other five, all insetup-project.py:--elected-by,git config user.name) and child output are whatever bytes they are, written through a UTF-8errors="replace"stream.--helpsaid--intodefaults to..always. It now also says that in self-bootstrap mode the effective default is the directory you ran the command from.OPENREPOSHAPE_REPOreachedgit cloneunguarded. It is now checked (empty, leading-, control characters refused; the refusal names the variable) and the clone argv carries--before the repository argument, so git never reads it as an option regardless.setup.shshares the exposure and is byte-frozen until One definition for the two entry points: setup.sh becomes a shim over setup-project.py (follow-up of #49) #50; noted there.PYTHON_CMDwasPath(sys.executable).name, not reliably retypable. It is now the platform-conventional command, exactly asscripts/repo_shape.py'sPYTHON;sys.executablestays for every argv._main()duplicated two strings that constants already existed for. Output byte-identical.Three new tests: a hostile
OPENREPOSHAPE_REPOrefuses with exit 2 and names the variable; the echoed clone line carries--; the preflight's bootstrap line namespython3/pythonby platform. Source still pure ASCII; every other printed string unchanged.Evidence:
python3 -m pytest tests -q→ 573 passed (570 onmain). Both CI jobs on this PR.Merge word: not yet given — awaiting Brett Heap.
🤖 Generated with Claude Code
Summary by Sourcery
Harden self-bootstrap setup validation and clarify its user-facing guidance while preserving existing output behavior.
Bug Fixes:
Enhancements:
Tests: