Skip to content

docs(commands): name CommandEnv's two constructors after what actually differs - #3970

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-33365619032
Aug 31, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-33365619032

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Surfaced by tonight's nightly survey of src/commands/context.rs.

CommandEnv::for_action_branchless is documented as "load the command environment without requiring a branch", but for_action doesn't require one either — both resolve branch from the same WorkingTree::branch() call, which returns Ok(None) in detached HEAD, and both leave the requirement to a later require_branch(). The only actual difference is where UserConfig comes from: for_action takes one from the caller, the other reads the repository's cached load.

The claim has been stale since #1750, which changed for_action's branch from a hard requirement to an Option. It survives in three places that all steer a reader the same wrong way — the constructor's name, its doc comment, and a comment at each of the two call sites (branch-optional for CI compatibility, Uses branchless mode). This renames it to for_action_loading_config and rewrites the three comments to state the config-source distinction.

No behavior change, so there's no regression test to add: the rename is mechanical (two call sites, both in hook_commands.rs) and the rest is comments. cargo clippy --all-targets --all-features and cargo fmt --check are clean, and cargo test --test integration hook_show (21) plus cargo test --lib --bins pass.

Why the two constructors are equivalent on branches

Both call repo.current_worktree().branch(), which resolves via rev-parse --symbolic-full-name HEAD and returns Ok(None) when detached rather than erroring (working_tree.rs). Repository::user_config() is a cached UserConfig::load_with_warnings() on RepoCache, so the two paths also agree on config content — they differ only in who supplies it.

Renaming rather than only correcting the doc, because a name that says "branchless" next to a sibling that is equally branchless is the part a reader trusts without opening the doc comment.

…y differs

for_action_branchless is documented as the one that doesn't require a
branch, but for_action stopped requiring one in #1750 — both resolve it
from the same WorkingTree::branch() call, which returns None in detached
HEAD. The real difference is the UserConfig source: caller-supplied vs
the repository's cached load.

Rename to for_action_loading_config and rewrite the doc plus the two
call-site comments, which repeated the same false premise.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Aug 31, 2026
@max-sixty
max-sixty merged commit 78552b7 into main Aug 31, 2026
36 of 46 checks passed
@max-sixty
max-sixty deleted the nightly/clean-33365619032 branch August 31, 2026 20:30
max-sixty pushed a commit that referenced this pull request Sep 1, 2026
The README's intro blockquote still opened with **August 2026**; today
is 2026-09-01, so the stamp is a month stale. This bumps it to
**September 2026** — the same monthly refresh as #3686 (August), #3347
(July), and #2972 (June).

Line 16 sits above the first `<!-- AUTO-GENERATED -->` marker (line 28),
so it is a hand-edited primary rather than generated content. It has two
mirrors, which behave differently:
`skills/worktrunk/reference/README.md` is a symlink to the root
`README.md` and picks the change up for free, while
`plugins/worktrunk/skills/worktrunk/reference/README.md` is a generated
*file copy* and needs its own sync — that second commit is here because
`test_docs_are_in_sync` caught the stale copy on the first push.

No regression test: the stamp is prose with no behavioral surface, and
its correctness is time-dependent rather than assertable.

<details><summary>Nightly sweep context</summary>

Found by the rolling survey (bucket 5/28) together with the README date
check in the repo's `running-tend` skill. The rest of the sweep was
clean:

- **tend config** — `tend check` all PASS; bot PAT carries every
required scope.
- **Conflicts** — #3129 (bot) and #3966/#3967/#3978 (Dependabot) all
test-merge clean against `main` via `git merge-tree`; no deferral
comments to clear.
- **Workflow regen** — `uvx tend@latest init` produced no diff; the
committed workflows are already at tend 0.1.24.
- **Recent commits** — the 7 commits in the last 24h reviewed; no
findings. The `for_action_branchless` → `for_action_loading_config`
rename in #3970 left no stale references, and #3976's `append_call_line`
change carries its own regression test.
- **Survey** — `src/cache.rs`, `src/config/user/path.rs`,
`src/config/user/sections.rs`, `src/styling/line.rs`,
`docs/src/content/docs/claude-code.md`, the two
`.config/clawpatch/features/*.json` files (every referenced path still
resolves), and the skill/plugin pages. No findings.

</details>

---------

Co-authored-by: worktrunk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants