Repository navigation
feat(config): show project identifier in wt config show - #2827
Conversation
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
left a comment
There was a problem hiding this comment.
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:
- Accept as a
?-propagation false positive on infalliblefmt::Write-to-String, or - 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]>
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 ofwt config show, so users can find the right key for[projects."..."]in their user config without hand-deriving it. Also adds anidentifierfield towt 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_remoteandtest_config_show_gitlab_remoteusedgit remote add origin …against the standard fixture, which already has anorigin.git remote addfailed silently (output isn't checked) and the test snapshotted the fixture's original../origin.gitURL instead of the platform URL it was meant to exercise. The new Identifier line in the regenerated snapshot made this visible; both tests now useset-url, matching the existingtest_config_show_full_gitea_remote.Test plan
cargo run -- hook pre-merge --yes(passes; nushell-onlyshell_wrapper::*::case_4failures are CI-environment, not regressions)cargo test --test integration— 1738/1738 passingcargo test --lib --bins— passingcargo test --test integration test_docs_are_in_syncwt config showin a repo with agithub.com:max-sixty/worktrunk.gitremote printsIdentifier: github.com/max-sixty/worktrunk