Skip to content

feat(init): preflight abort on non-main default branches - #1291

Merged
c-vigo merged 5 commits into
devfrom
feature/1283-master-preflight
Jul 29, 2026
Merged

c-vigo merged 5 commits into
devfrom
feature/1283-master-preflight

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

On a legacy master repo the scaffold succeeded silently — then every commit was blocked by the scaffolded branch-name hook (which only permits main/dev/convention branches), with ci.yml's trunk rewrite and workflow triggers equally keyed to main. The failure surfaced at the worst moment: the first commit after adoption.

install.sh now refuses to scaffold before anything is written when the default branch is not main, printing the two-command rename recipe (git branch -m master main && git push -u origin main; gh repo edit --default-branch main) and a docs/MIGRATION.md pointer. The check lives host-side in install.sh (next to the #886 run_preflight_guard) because the container-side init-workspace.sh has no git-branch visibility.

Behavior

  • Resolution order: origin/HEAD → best-effort gh api default_branch (GitHub origin only; offline-safe, timeout 5, errors swallowed) → current branch for local-only repos; unresolvable states defer to the existing guard.
  • Runs on fresh installs AND --force (first-time adoption is the core case). --preview warns without aborting; --smoke-test and --skip-preflight skip it.
  • A non-main default is accepted when a main ref already exists (local or origin) — the gitflow topic/dev-branch case. Conforming repos see no behavior change.
  • New docs/MIGRATION.md subsection "Legacy default branches (master)" under Workflow models.

Test evidence

Merge order

Part of the #1280–#1285 solo-adoption batch; recommended merge order #1281 → #1280 → #1283 → #1282 → #1284 → #1285.

Closes #1283

c-vigo added 5 commits July 29, 2026 12:47
The scaffolded justfile.project test/test-cov recipes gate on pyproject.toml
presence, so a consumer with a pyproject.toml but no test suite ran
uv run pytest and got exit 5 ("no tests collected"), turning just test and CI
red out of the box. Both recipes now swallow pytest's exit 5 while propagating
every other nonzero exit, so "nothing to test" no-ops green like non-Python
consumers already do.

Refs: #1281
The #1283 default-branch preflight refuses a repo where no main can be
resolved; the #886 dry-run fixture was a lone feature branch. Non-testable
via bats (pytest-owned fixture).

Refs: #1283
@c-vigo
c-vigo force-pushed the feature/1283-master-preflight branch from 86701a6 to db18ccb Compare July 29, 2026 12:56
@c-vigo
c-vigo merged commit cf2de0f into dev Jul 29, 2026
13 checks passed
@c-vigo
c-vigo deleted the feature/1283-master-preflight branch July 29, 2026 13:06
c-vigo added a commit that referenced this pull request Jul 29, 2026
## Summary

New `docs/SOLO_ADOPTION.md`: the one document a single-user, private
repo follows to adopt devkit without the team/traceability layer —
expressed purely as a combination of existing knobs, no new mode.
Distilled from the beancount-repo adoption evaluation that produced
#1280–#1284.

The recipe: `--mode devcontainer --workflow trunk` +
`DEVKIT_FEATURES_DISABLED=release,sync-issues,scanning,skills,worktree,gh-templates`
+ `DEVKIT_REFS_POLICY=optional`, with the accurate two-step apply flow
(both are manifest-only keys: scaffold, set keys, `--force` re-render,
`--preview` first). The guide states what is KEPT (hook stack, commit
type/format validation, agent-identity enforcement, managed upgrade
path, justfiles, dev env, `ci.yml`) as clearly as what is dropped, calls
out `renovate` as a kept-by-default judgment call (preserved-class
`renovate.json` never pruned), warns about forward drift (new feature
groups arrive enabled), and cross-links the three adoption notes that
trip solo adopters (#1283 `main` default branch, #1280 undotted
`typos.toml`, #1281 zero-test Python repos). A `--profile solo`
installer flag is explicitly out of scope (possible follow-up against
#1285).

Also: README pointer in the install section (edited via
`docs/templates/README.md.j2` — README is generated — and regenerated
with `just docs`), MIGRATION.md cross-link bullet in the manifest
section, changelog Added entry.

## ⚠️ Merge order — merge LAST

Depends on #1292 (`DEVKIT_REFS_POLICY`, #1282) and #1293
(`DEVKIT_FEATURES_DISABLED`, #1284): the guide documents those keys and
links MIGRATION.md anchors that land with #1291/#1293. Recommended batch
order: #1290 → #1291 → #1292 → #1293 → this.

## Verification

Docs-only (no TDD — no runtime surface). `prek run --all-files` green;
`just docs` confirms README regenerates identically from the template.

Closes #1285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant