Skip to content

Normalize the Link checkout folder before checking and saving it #87

Closed

Description

@HemSoft

Description

Manage > Projects > Link checkout passes the typed folder to projects::link_checkout as PathBuf::from(folder) (crates/dashboard-app/src/manage/projects.rs:758). Config::add_repository (crates/dashboard-core/src/config.rs:160) treats it as already listed only when it is == to an existing entry, then writes it to config.toml as typed. Two consequences, reproduced on b6b5450 with synthetic temporary checkouts on Windows (git 2.55):

  1. Another spelling of a listed checkout adds a second row. With repositories = ["…\src\hs-buddy"], linking …\src\sub\..\hs-buddy or …\src\HS-BUDDY returns Ok, appends the path, and Board::new builds 2 cards for one checkout. Both read identity hemsoft-dev/hs-buddy. Control: the exact path and the path with a trailing / leave the list unchanged with 1 card.
  2. A relative folder depends on the process working directory. With the working directory set to …\src, linking hs-buddy returns Ok and writes repositories = ["hs-buddy"]. Once the working directory changes, checkout_identity("hs-buddy") returns Err(Identity) and the row shows "Repository identity unavailable". Control: the absolute path still resolves from the other working directory.

The .. case also applies on Linux and macOS. The case-only spelling applies where the filesystem ignores case.

Why

A duplicate row fetches and shows the same project twice. A relative entry passes validation, is saved, then fails on a later start from a different directory (for example a shortcut or Explorer launch) with an identity error that hides the cause.

Goal

Link checkout saves one stable absolute path per checkout and recognizes a folder that is already listed under another spelling.

Acceptance Criteria

  • Linking a relative folder either resolves it to an absolute path before it is checked and saved or is refused with a message asking for a full path. config.toml never gets a relative entry from Link checkout.
  • Linking a folder that refers to an already listed checkout through .. or a case-only difference (on case-insensitive filesystems) writes nothing and adds no row.
  • Linking the exact listed path, or that path with a trailing separator, still writes nothing.
  • A new absolute folder with the right origin is still appended once, with the file's comments kept (existing Add a Projects dialog to track, edit and re-prioritize pmd projects #34/Write config.toml atomically and cover view saves #73 behavior).
  • Saved paths keep a normal form on Windows (no \?\ verbatim prefix in config.toml).

Definition of Done

  • Fix in dashboard-core with tests named after the behavior, covering the relative, .., case-only (Windows) and exact or trailing-separator cases.
  • Failure paths covered: a relative or nonexistent folder writes nothing.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test --workspace --locked and cargo deny --locked check advisories pass.
  • Clean current-head AI review.

Validation

  • cargo test -p dashboard-core --locked runs the new tests. In a temporary folder with a .git/config origin of https://github.com/hemsoft-dev/hs-buddy.git and config.toml listing that checkout, link_checkout(dir, <root>/sub/../hs-buddy, "hemsoft-dev/hs-buddy") leaves Config::load(dir).repositories at one entry.

  • With the working directory set to the parent of that checkout, linking hs-buddy never leaves "hs-buddy" in config.toml.

  • The resulting PR's ## Validation embeds current-head screenshots, rendered offscreen by the headless capture test (captures::captures on Linux, synthetic temporary folders, no real profile), of Manage > Projects > Link checkout in three states: a relative folder refused with the full-path message; a missing folder; and a .. spelling of a checkout already listed, reported under its listed path with config.toml unchanged. Each state is one button press, so no recording is required.

Evidence from branch fix/issue-87-normalize-link-checkout-folder at c7d344790c6c96b223fe46f694055990c155ab64:

Link checkout refuses the relative folder hs-buddy with the full-path message

Link checkout reports that the missing folder doesn't exist

Link checkout reports the already-listed hs-buddy path for a dot-dot spelling and writes nothing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions