Repository navigation
Empty $OPENREPOSHAPE_REPO means unset, the standard's own .gitattributes, the shim's --shape-ref length bound (#63) - #65
Conversation
…tes, 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]>
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 11 hours and 8 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideThe PR reconciles repository fallback semantics, line-ending normalization, and shape-reference validation between the Python and shell entry points, with focused offline, hygiene, CRLF, and boundary tests to prevent the implementations from drifting. Sequence diagram for repository fallback in both entry pointssequenceDiagram
participant Env as Environment
participant Python as setup-project.py
participant Shell as setup.sh
participant Git as git clone
Env->>Python: OPENREPOSHAPE_REPO
alt unset or empty
Python->>Git: clone DEFAULT_SHAPE_REPO
else non-empty
Python->>Python: checked_value
Python->>Git: clone validated repository
end
Env->>Shell: OPENREPOSHAPE_REPO
alt unset or empty
Shell->>Git: clone DEFAULT_SHAPE_REPO
else non-empty
Shell->>Git: clone repository
end
Flow diagram for shape-reference length validationflowchart TD
A[Read --shape-ref] --> B{Syntax rules pass?}
B -- No --> C[die with ref validation error]
B -- Yes --> D{Length greater than 255?}
D -- Yes --> E[die with length error]
D -- No --> F[git checkout validated ref]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🟡 Changes recommended
setup.sh still echoes the raw --shape-ref value in an error path, allowing control characters (notably newlines) to forge extra stderr lines unless the guard is reordered and a non-printable check is added.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aligns small but important edge-case behaviors across the two setup entry points and hardens cross-platform line-ending handling, primarily by adding regression tests and tightening the shim’s --shape-ref validation to match the Python rules.
Changes:
- Add offline regression tests ensuring
OPENREPOSHAPE_REPO=""falls back to the default repo in bothsetup.shandsetup-project.py. - Make
tests/test_update_shape_add.py::unname_everywhere()tolerant of CRLF sources and add a direct CRLF-focused unit test. - Add a repository-root
.gitattributesand hygiene tests asserting the root and templates agree on the LF rule; extend shim tests for a 256-character--shape-ref.
File summaries
| File | Description |
|---|---|
tests/test_update_shape_add.py |
Switches copy-list entry stripping to CRLF-tolerant regex and adds a focused CRLF regression test. |
tests/test_setup_sh.py |
Adds offline test for empty OPENREPOSHAPE_REPO defaulting and extends shim --shape-ref rejection coverage to 256 chars. |
tests/test_setup_project_py.py |
Extends Python --shape-ref rejection coverage to 256 chars and adds offline test for empty OPENREPOSHAPE_REPO defaulting. |
tests/test_repo_hygiene.py |
Adds checks that the repo root also carries the LF .gitattributes rule and that root/templates agree on the rule line. |
setup.sh |
Adds a --shape-ref length guard (255) and updates the mirror comment to include the bound. |
setup-project.py |
Corrects the OPENREPOSHAPE_REPO comment to reflect that empty means “unset” (truthiness fall-through). |
.gitattributes |
Introduces a root-level LF normalization rule to avoid CRLF-caused test brittleness on Windows clones. |
Review details
- Files reviewed: 7/7 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.
| 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 | ||
| if [ "${#SHAPE_REF}" -gt 255 ]; then | ||
| die "--shape-ref is ${#SHAPE_REF} characters long; a branch, tag or commit this tool will pass to \`git checkout\` is at most 255 characters." | ||
| fi |
There was a problem hiding this comment.
Folded in as aa1d5c9: three checks in order — length, then control character, both refusing without echoing the value (like the OPENREPOSHAPE_REPO guard above), then the shape case, which by then only sees a printable ref of at most 255 characters. Tests: a newline-carrying ref's forged line never reaches stderr; the over-long case is parametrised over a legal and an illegal shape, neither echoed. Lane: xfactory-2 (xFactory-2)
There was a problem hiding this comment.
🟢 Approval recommended
The functional changes are small, well-covered by new targeted tests, and the remaining findings are minor comment/naming nits rather than correctness risks.
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
| # 255 characters long. Only reached when $SHAPE_REF is non-empty — every | ||
| # alternative below requires at least one character to match. The LENGTH | ||
| # bound is checked separately, below, rather than folded into this `case`: |
| if line.strip() and not line.lstrip().startswith("#")] | ||
|
|
||
|
|
||
| def test_the_repositorys_own_root_carries_the_rule_too(): |
…hape-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]>
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive, well-tested (including offline and platform-specific edge cases), and the remaining feedback is a minor docstring wording nit.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
tests/test_update_shape_add.py:99
- Docstring says the line ending is “OPTIONAL (\r?\n)”, but
\r?\nmakes only the\roptional (LF vs CRLF), not the newline itself. Reword to avoid implying the entry line might have no trailing newline.
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
…e newline is required (#66) (#67) Copilot's suppressed comment on PR #65, read after the merge: the docstring said the line ending is "OPTIONAL (\r?\n)", which implies the entry line might carry no newline at all. It cannot: \r?\n makes only the carriage return optional, and the entry is matched as a whole line. Reworded to say so and to keep the reason the \r is optional - a core.autocrlf=true checkout has CRLF throughout until it is renormalised. No code changes. Lane: xfactory-2 (xFactory-2) Co-authored-by: Claude Fable 5.1 <[email protected]>



Lane: xfactory-2 (xFactory-2)
Claim: #63 (claim in the issue body, 2026-09-06T02:24Z, on Brett Heap's "pick up 12-14 and merge on green too")
Closes #63.
Three Copilot inline comments read AFTER their PRs merged (#56 for #55, #58 for #51, #60 for #50) and deferred as cosmetic. None changes behaviour a user sees today; each left a statement in the tree that was not true, or a bound that existed in one entry point and not in the other.
1. An explicitly EMPTY
$OPENREPOSHAPE_REPOmeans unset (Copilot on #56)self_bootstrap()reads the variable with a truthiness test, soOPENREPOSHAPE_REPO=falls toDEFAULT_SHAPE_REPO— while the comment above the read saidchecked_valuerefuses "an empty value", which it is never reached for.setup.shreads the same variable as${OPENREPOSHAPE_REPO:-<default>}: empty is unset there too.Ruling (recorded on #63): empty means unset, in both entry points — the shell's own
${VAR:-default}reading, and the two entry points already agreed. Behaviour unchanged; the comment now says what the code does. One test per entry point pins it, OFFLINE:GIT_CONFIG_COUNT/_KEY_0/_VALUE_0give the child process aurl.<file-uri-of-this-checkout>.insteadOf <default>rewrite, so the clone of the DEFAULT repository resolves to this checkout without a network — the echoedgit cloneline naming the default URL is the proof that the empty value fell through to it. Each test also asserts its literal equals the source's own default, so they cannot drift apart. (GIT_CONFIG_COUNTneeds git ≥ 2.31; the three runners and this box have 2.4x.)2. The standard's own root gets a
.gitattributes; the test helper tolerates CRLF (Copilot on #58)tests/test_update_shape_add.py::unname_everywhere()stripped"<entry>",\n— a checkout made under Git for Windows'core.autocrlf=truedefault has CRLF sources, the helper stripped nothing, and #51's tests would fail on a machine whose only sin was that default. CI never saw it (Linux/macOS check out LF; the Windows job pinsautocrlf=false). #51 gave the two TEMPLATES a.gitattributes; the standard's own root had none..gitattributeswith the templates' rule* text=auto eol=lfand its own header (why the STANDARD wants LF bytes: its suite reads its sources as text, andshape_materializecopies their bytes into projects that pin digests).git add --renormalize .is a no-op: every tracked file is alreadyi/lf.tests/test_repo_hygiene.py: the root carries exactly that rule; root and both templates agree on the rule line (headers differ on purpose).unname_everywherematches\r?\n, because a checkout made before this lands keeps its CRLF until renormalised; one direct test feeds it a CRLF source.3. The shim's
--shape-refguard getsREF_RE's length bound (Copilot on #60)The
caseinsetup.shmirroredREF_RE's alphabet, first character,..and.lockrules but not its length ({0,254}after the first character: at most 255). An over-long ref reachedgit checkoutin the temporary clone where the Python would have refused it at parse time.if [ "${#SHAPE_REF}" -gt 255 ]; then die ...; fiafter thecase— bash 3.2-clean; the refusal names the LENGTH, not the value (256+ characters of noise on stderr is not a fault a person can read).--shape-refand255, exits 2, and does not echo the value.What did not change
Behaviour of either entry point on any input a user types today; README.md and AGENTS.md (caps unchanged); the templates.
Tests
git version 2.43.0).bash -n setup.shpasses;tests-macosis the length check's first run under stock bash 3.2.tests-windows: the Python-side empty-variable test runs there (the shim tests skip, as before); thefile://URI carries no backslashes.Review
aa1d5c9): (1) the shapecaseechoed the raw--shape-refin its refusal, so a control character could forge a stderr line and an over-long ref that also failed the shape was echoed as noise → three checks now run in order: length, then control character — both refusing WITHOUT echoing the value, like theOPENREPOSHAPE_REPOguard above them — then the shapecase, which by then only ever sees a printable ref of at most 255 characters; two new tests (a newline-carrying ref is refused and the forged line never reaches stderr; the over-long case is parametrised over a legal and an illegal shape, neither echoed). (2) The "only reached when$SHAPE_REFis non-empty" comment was inaccurate (thecaseruns and matches nothing) → reworded. (3)test_the_repositorys_own_root…→test_the_repository_root_carries_the_rule_too.[[instead of[") on the new length check, is deliberately NOT taken: the shim uses POSIX[in its four existing tests, and one[[would be the odd construct out in a file whose point is to be plain bash 3.2.b17ede6); taken as a merge commit2bb8575(the ruleset refuses force-push). Both PRs editedtests/test_repo_hygiene.pyin disjoint regions; the merge was clean and The optional MedxEHR clone comes from SHAPE_MEDXEHR_CLONE, and a guard keeps host paths out of the tree (#61) #64's host-path guard passes over everything this PR adds.Summary by Sourcery
Align repository and reference validation across both setup entry points while making line-ending handling consistent and safe.
Bug Fixes:
Enhancements:
Tests: