Skip to content

Say what a worktree run refuses, and test the refusals - #168

Merged
adamw merged 1 commit into
masterfrom
worktree-run-docs-tests
Sep 11, 2026
Merged

Say what a worktree run refuses, and test the refusals#168
adamw merged 1 commit into
masterfrom
worktree-run-docs-tests

Conversation

@adamw

@adamw adamw commented Aug 28, 2026

Copy link
Copy Markdown
Member

Closes the four doc and test gaps the review of #166 left open. Docs and
tests only — no behaviour change.

Worktrees' object doc talked about "the two reads", which the object
has outgrown. It now states the rule for all of the reads, and names
mainCheckoutOrReason as the one that gives a reason instead of a blank
"not known".

WorktreeRun.resolve's doc listed three of the messages a caller can
get back. It lists all of them now, and says what each one means.

Two of the three "no main checkout" messages had no test: the one for
a repository whose main worktree is not a checkout (--separate-git-dir
or a submodule), and the one for a git that does not answer the query.
The second is reached with a repository path holding a newline, which
makes git's answer unreadable in the same way an old git does.

headBranch and onABranch answer "not on a branch" when a worktree
cannot be read at all
, which nothing tested. The new test deletes the
worktree directory first, so git really cannot be run there; it fails if
that fail-closed answer is taken out. os-lib prints the failed exec's
stack trace from a thread of its own, so the test log shows it while
passing — noted in the test.

The --separate-git-dir repo two tests were building inline is now
GitRepo.seededSeparateGitDir.

sbt scalafmtAll and sbt test are green: 2239 tests, 0 failures.

Closes the four doc and test gaps the worktree-runs review left open.

`Worktrees`' object doc talked about "the two reads", which the object
has outgrown; it now states the rule for all of them, and names
`mainCheckoutOrReason` as the read that gives a reason instead.

`WorktreeRun.resolve`'s doc listed three of the messages a caller can
get back. It lists all of them now.

Two of the three "no main checkout" messages had no test: the one for a
repository whose main worktree is not a checkout, and the one for a git
that does not answer the query. Both are covered.

`headBranch` and `onABranch` answer "not on a branch" when a worktree
cannot be read at all, which nothing tested. The new test deletes the
worktree directory first, so git really cannot answer.

The separate-git-dir repo two tests were building inline is now
`GitRepo.seededSeparateGitDir`.
@adamw
adamw merged commit 0005f1e into master Sep 11, 2026
6 checks passed
@adamw
adamw deleted the worktree-run-docs-tests branch September 11, 2026 07:38
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