Repository navigation
setup.sh: fork, clone, run one command - #2
Conversation
Brett, 2026-09-02: "can we put a setup.sh in the repo so we fork, clone, then run setup.sh to finish?" This is that, and nothing more: it shells out to the same `validate-repository-naming.py`, `scaffold-project.py` and `make bootstrap` the README already documents, in the same order, adding no behaviour of its own. The README's new "What setup.sh does" section is those commands, so a person who prefers to run them by hand gets the same result. It is the FIRST thing a person runs in a fork, before they know anything about the repository, so it works with what is on the machine: preflight names git, python3 (>=3.9), make and gh with a tick or a precise fix hint, and refuses on a missing one rather than failing halfway through. THE GUARD THAT EARNS ITS KEEP: `gh repo fork --clone` leaves you in your fork and `git clone opensoft/openRepoShape` leaves you in the upstream, and from inside the directory those look identical. The organisation is detected from the clone's own origin (`gh repo view`, falling back to parsing the remote URL when offline), and scaffolding into `opensoft` REFUSES unless `--allow-upstream-org` is passed. That refusal applies in every mode, `--local-remote-dir` included: what a local run skips is org DETECTION, not the refusal, because `--org` is what a scaffolded `project.yaml` records as the owner of all three legs, and a manifest reading `opensoft/Sample` written from an upstream clone is exactly as wrong as three repositories in the wrong place. Nothing is created before an explicit `yes`: the plan is a real `scaffold-project.py --dry-run` and the prompt accepts that word only. With no terminal and no `--yes` it refuses after showing the plan rather than guessing. `--local-remote-dir` is the test path — three bare repositories on disk, no network, no `gh`, no real repository — and `tests/test_setup_sh.py` drives the script end to end through it: exit 0, the clone where `--into` says, both legs on `main`, the degrade line printed, plus the refusals (unknown flag, bad visibility, a name outside the policy stopping BEFORE the scaffold, the upstream-org guard, no-terminal-no-yes, and `--` pass-through reaching the scaffold). AGENTS.md now tells an assistant to run setup.sh WITHOUT `--yes` and let the human answer its prompt, and never to pass `--allow-upstream-org` on its own initiative — if setup.sh refuses on it, stop and relay what it said. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
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 18 hours and 19 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideIntroduces setup.sh as a guarded, confirmation-based orchestration layer for the existing naming validation, scaffolding, cloning, and bootstrap commands, with offline support and comprehensive documentation and tests. Flow diagram for the setup.sh orchestrationflowchart TD
A["./setup.sh --project Project"] --> B["Preflight git, python3, make, gh"]
B --> C["Detect organisation from origin or --org"]
C --> D{"Upstream organisation?"}
D -->|"Yes, no escape flag"| X["Refuse before scaffolding"]
D -->|"No or allowed"| E["Validate Project, Project-spec, Project-code"]
E --> F{"Naming policy passes?"}
F -->|"No"| Y["Refuse before repositories exist"]
F -->|"Yes"| G["Run scaffold-project.py --dry-run"]
G --> H{"Explicit yes or --yes?"}
H -->|"No"| Z["Refuse; nothing created"]
H -->|"Yes"| I["Run scaffold-project.py"]
I --> J["Clone assembly root with submodules"]
J --> K["make bootstrap or python3 scripts/bootstrap.py"]
K --> L["Print clone path, repository URLs, and next commands"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
`test_no_project_and_no_terminal_refuses` ran WITHOUT `--local-remote-dir`, so it reached the real `gh auth status` preflight and refused for that reason instead of the one it asserts. It passed on an authenticated laptop and failed in CI, which is the whole failure mode: a test whose answer depends on who is logged in is not testing the script. Fixed, and made a rule rather than a convention: `test_no_test_here_depends_on_gh_being_authenticated` scans every `run_setup` call in this file and requires `--local-remote-dir` on all but the three argument-parsing refusals, which the script answers before it looks at the machine at all. Verified both ways: 104 passed with a logged-in `gh`, and 104 passed with GH_CONFIG_DIR pointed at nothing. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
There was a problem hiding this comment.
🟡 Changes recommended
setup.sh’s --local-remote-dir path can refuse unnecessarily when git config user.name is unset despite common CI Git identity env vars being available, making offline/local runs brittle.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a single setup.sh entry point to make scaffolding a new project from an openRepoShape fork a one-command flow, while keeping the underlying implementation delegated to the existing Python scaffold + bootstrap tooling.
Changes:
- Add
setup.shto perform preflight checks, org detection (with upstream-org guard), naming validation, dry-run plan display + confirmation, then scaffold/clone/bootstrap. - Add end-to-end tests for
setup.sh(local/offline path + refusal scenarios) and repo hygiene checks ensuringsetup.shis executable, uses safe shell flags, and is documented. - Update README and AGENTS procedure to make
setup.shthe primary documented entry point and to codify the “no--yes/ no implicit--allow-upstream-org” assistant rules.
File summaries
| File | Description |
|---|---|
| tests/test_setup_sh.py | End-to-end + refusal-path coverage for the new setup.sh flow using --local-remote-dir. |
| tests/test_repo_hygiene.py | Adds hygiene assertions for setup.sh executability, bash parsing, and documentation references. |
| setup.sh | New top-level orchestrator script wrapping preflight/org detection/plan confirmation/scaffold/clone/bootstrap. |
| README.md | Documents ./setup.sh --project ... as the primary “new org flow” and lists the equivalent manual commands. |
| AGENTS.md | Updates the assistant procedure to route through setup.sh and reinforces guardrails around confirmation and upstream-org protection. |
Review details
- Files reviewed: 5/5 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.
| if [ -z "$ELECTED_BY" ] && [ "$LOCAL_MODE" -ne 1 ]; then | ||
| ELECTED_BY="$(gh api user --jq .login 2>/dev/null || true)" | ||
| fi | ||
| if [ -z "$ELECTED_BY" ]; then | ||
| ELECTED_BY="$(git config user.name 2>/dev/null || true)" | ||
| fi | ||
| if [ -z "$ELECTED_BY" ]; then | ||
| die "cannot work out who is electing this shape. Re-run with --elected-by 'Your Name' — the manifest records whose act it was." | ||
| fi |
There was a problem hiding this comment.
🔵 Needs a closer look
There are a couple of concrete reliability issues in setup.sh (notably offline --elected-by fallback and recovery instructions when make is absent) that can cause unexpected refusals or misleading guidance.
Review details
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
setup.sh:329
- If the clone destination already exists, the refusal message always tells users to run
make bootstrap, but earlier preflight explicitly allowsmaketo be absent (and the script later falls back topython3 scripts/bootstrap.py). The recovery instructions should match the detected bootstrap mechanism so users aren’t sent to a command that may not exist.
setup.sh:247
- In local/offline mode,
--elected-bycurrently falls back only togit config user.nameand then refuses if that is unset. This makessetup.sh --local-remote-dir ...brittle in CI or fresh environments where no git identity is configured, even though the script already sets Git author/committer env vars in tests and could use those as a last-resort elector name.
if [ -z "$ELECTED_BY" ]; then
ELECTED_BY="$(git config user.name 2>/dev/null || true)"
fi
if [ -z "$ELECTED_BY" ]; then
die "cannot work out who is electing this shape. Re-run with --elected-by 'Your Name' — the manifest records whose act it was."
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
Brett, 2026-09-02: "can we put a setup.sh in the repo so we fork, clone, then
run setup.sh to finish?" This is exactly that.
What it does
It adds no behaviour of its own. It shells out to the same
scripts/validate-repository-naming.py,scaffold-project.pyandmake bootstrapthat #1 shipped and the README documents, in the same order,so a person who prefers to run those by hand gets an identical result — the
README's new "What setup.sh does" section is those commands verbatim.
git,python3(≥3.9),make,gh+gh auth status,each with a tick or a precise fix hint; exit 2 on a missing prerequisite.
makeabsent is a tick, not a failure: bootstrap falls back topython3 scripts/bootstrap.py.originviagh repo view --json owner --jq .owner.login, falling back to parsing theremote URL when offline.
--orgoverrides.gh repo fork --cloneleaves you inyour fork;
git clone opensoft/openRepoShapeleaves you in the upstream;from inside the directory those look identical. Scaffolding into
opensoftrefuses unless
--allow-upstream-orgis passed.--explainon all three; afinding stops the run before the scaffold.
yes— a realscaffold-project.py --dry-run, then a prompt that accepts that word only. With no terminal andno
--yesit refuses after showing the plan rather than guessing.../<Project>, or--into <dir>) with--recurse-submodules, thenmake bootstrap, then afinal block naming the clone path, the three repository URLs and the next
commands.
--local-remote-dir <dir>is the test path: three bare repositories on disk,no network, no
gh, no real repository.Also in this PR
tests/test_setup_sh.py— drives the real script end to end through thelocal path and asserts exit 0, the clone where
--intosays, both legs onmainafter bootstrap, and the degrade line printed; plus every refusal(unknown flag, bad visibility, a name outside the policy stopping before
the scaffold, the upstream-org guard and its
--allow-upstream-orgescape,no-terminal-no-
--yes, and--pass-through reaching the scaffold)../setup.sh, with themanual steps kept underneath as "What setup.sh does".
--yesand lets thehuman answer its prompt, and never passes
--allow-upstream-orgon its owninitiative; if setup.sh refuses on it, stop and relay what it said.
tests/test_repo_hygiene.py— setup.sh is executable, starts with#!/usr/bin/env bash, carriesset -euo pipefail, parses underbash -n,and is the front door both docs point at.
Deviation worth flagging
The upstream-org refusal applies in every mode,
--local-remote-dirincluded. What a local run skips is org detection, not the refusal:
--orgis what a scaffolded
project.yamlrecords as the owner of all three legs, soa manifest reading
opensoft/Samplewritten from an upstream clone is exactlyas wrong as three repositories in the wrong place — and it makes the guard
testable without a network. A local run that names no
--orggets thelocalorgplaceholder, so the guard never fires by surprise.Tests
python3 -m pytest tests -q🤖 Generated with Claude Code
https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
Summary by Sourcery
Provide a safe one-command workflow for forking, scaffolding, cloning, and bootstrapping a new project shape.
New Features:
Enhancements:
Documentation:
Tests: