Skip to content

feat(config): show project identifier in wt config show - #2827

Merged
max-sixty merged 2 commits into
mainfrom
feat/config-show-project-identifier-2826
May 20, 2026
Merged

max-sixty merged 2 commits into
mainfrom
feat/config-show-project-identifier-2826

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Closes #2826. Surfaces the project identifier (<host>/<owner>/<repo> from the primary remote, or the canonical repo path as a fallback) in the PROJECT CONFIG section of wt config show, so users can find the right key for [projects."..."] in their user config without hand-deriving it. Also adds an identifier field to wt config show --format=json.

Docs expand the User project-specific settings section with the new how-to-find-it note plus single/concurrent/pipeline hook examples — the reporter's TOML showed both pieces were unclear, even though the array-of-tables form they tried was correct.

Drive-by

test_config_show_github_remote and test_config_show_gitlab_remote used git remote add origin … against the standard fixture, which already has an origin. git remote add failed silently (output isn't checked) and the test snapshotted the fixture's original ../origin.git URL instead of the platform URL it was meant to exercise. The new Identifier line in the regenerated snapshot made this visible; both tests now use set-url, matching the existing test_config_show_full_gitea_remote.

Test plan

  • cargo run -- hook pre-merge --yes (passes; nushell-only shell_wrapper::*::case_4 failures are CI-environment, not regressions)
  • cargo test --test integration — 1738/1738 passing
  • cargo test --lib --bins — passing
  • cargo test --test integration test_docs_are_in_sync
  • Verified manually: wt config show in a repo with a github.com:max-sixty/worktrunk.git remote prints Identifier: github.com/max-sixty/worktrunk

The `[projects."<id>"]` user-config section is keyed by an identifier
worktrunk computed internally but never surfaced, so users had to guess
or hand-derive it from their remote URL (#2826). Print it inside
PROJECT CONFIG and expand the docs with a how-to-find-it note plus
single/concurrent/pipeline hook examples for the projects table.

Also expose the identifier in the `--format=json` output, and fix the
github/gitlab remote tests that used `git remote add` on a fixture
which already had `origin` — the add silently failed, so the snapshots
were testing the wrong URL.

Closes #2826

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review. The change is well-scoped: it reuses the existing Repository::project_identifier() (no duplication), primary_remote_url() is a config-only read so this stays within the "no network on wt config show" rule, and the snapshot updates match what src/cli/mod.rs now emits. The drive-by set-url fix to test_config_show_github_remote / test_config_show_gitlab_remote is a real bug: git remote add origin … on a fixture that already has origin silently failed and the prior snapshots were testing the fixture's ../origin.git URL rather than github/gitlab — switching to run_git + set-url makes the next regression loud.

One concern worth a human eye:

codecov/patch failed on src/commands/config/show.rs lines 768–769 ()?; and the closing } of the new if let Ok(project_id) = … block). out: &mut String, so writeln!(out, …)? is propagating an error that impl fmt::Write for String never returns — LLVM marks the cleanup edge of ? as a missed line. The same shape is used by every other writeln!(out, …)?; in this function and they pass coverage only because they're not in the patch's added-lines window. Per CLAUDE.md ("NEVER merge a PR with failing codecov/patch without explicit user approval") I'm flagging this rather than self-approving — would appreciate a maintainer call on whether to:

  1. Accept as a ?-propagation false positive on infallible fmt::Write-to-String, or
  2. Drop the ? for this one call site (let _ = writeln!(…);), inconsistent with the surrounding pattern but covers the gap.

Everything else looks good — flagging just the gate.

Codecov flagged the closing `)?;` and `}` of the multi-line writeln as
uncovered patch lines. The if-let-Ok branch is hit by every test that
reaches `render_project_config`, but llvm-cov attributes coverage only
to the first source line of the macro call. Hoisting the formatted
string into a local and emitting a single-line `writeln!(out, "{line}")?;`
collapses it to one instrumentation point.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty
max-sixty enabled auto-merge (squash) May 20, 2026 06:18
@max-sixty
max-sixty merged commit 7f36ece into main May 20, 2026
31 checks passed
@max-sixty
max-sixty deleted the feat/config-show-project-identifier-2826 branch May 20, 2026 06:21
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.

Print project identifier in wt config state get

2 participants