Skip to content

Keep a Drive Root's Separator and Judge a Literal Percent in Path Cleanup - #3874

Merged
ptr727 merged 2 commits into
developfrom
feature/path-cleanup-keys-3862
Nov 4, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/path-cleanup-keys-3862

Conversation

@ptr727

@ptr727 ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Part of #3862, answering Copilot's round on promotion #3873.

Why

Copilot's round on the promotion raised two real defects in the -CleanPath duplicate and variable checks that #3872 added.

  • The duplicate key trimmed C:\ to C:. C: names the current directory on drive C rather than its root, so a C: entry was removed as a repeat of C:\.
  • Any % left after expansion marked an entry as unexpanded. A directory whose name holds a literal % was therefore never judged. This is the second round to raise it.

What Changed

  • Get-PathEntryKey holds the duplicate key. A drive root keeps its \, and a bare C: stays C:.
  • An entry is unjudged as unexpanded only where a whole %NAME% token survives expansion.
  • Two tests cover both.

Verification

  • tests/test_upgrade_host.py 26 OK natively on Windows.
  • ruff, mypy, the prose gate, and PSScriptAnalyzer are clean.
  • A local strict review of the diff raised nothing.

🤖 Generated with Claude Code

…anup

Answers Copilot's round on promotion #3873.

- The duplicate key no longer trims C:\ to C:, which names the current
  directory on that drive rather than its root. So a C: entry is no
  longer removed as a repeat of C:\.
- An entry is left unjudged as unexpanded only where a whole %NAME%
  token survives expansion, so a directory whose name holds a literal %
  is judged like any other.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 4, 2026
Copilot AI lite review requested due to automatic review settings November 4, 2026 19:45
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 33ff97006c526c8f47b187c7ce2b137456701707, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Two active nit findings remain in upgrade-host.ps1: comments at lines 357 and 390 need grammar and sentence-completeness fixes to improve clarity.

2 open issues
What changed in this PR

This pull request fixes Windows path-cleanup edge cases by preserving drive-root semantics and distinguishing literal percent characters from unresolved environment-variable tokens.

Changes:

  • Preserves the separator in duplicate keys for drive roots while keeping bare drive-relative paths distinct.
  • Detects surviving %NAME% tokens rather than treating every percent character as unexpanded.
  • Adds regression tests for drive-root handling and literal-percent paths.
File Summary Review findings
tests/​test_upgrade_host.py Adds regression coverage for drive roots and literal percent characters. No findings.
host-setup/​windows/​upgrade-host.ps1 Updates path-key normalization and unexpanded-variable detection. Moderate finding: variable-token detection excludes backslashes, so unresolved tokens such as C:\%SDK\ROOT%\bin may be judged incorrectly. Two nit findings request clearer comment grammar.

Review effort: Lite

Comment thread host-setup/windows/upgrade-host.ps1 Resolved
Comment thread host-setup/windows/upgrade-host.ps1 Resolved
Answers Copilot's round on 33ff970.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head a02525292e00f2fb090115349049140547e32765, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.31%. Comparing base (0c2e2f3) to head (a025252).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3874   +/-   ##
========================================
  Coverage    83.31%   83.31%           
========================================
  Files           29       29           
  Lines         9956     9956           
========================================
  Hits          8295     8295           
  Misses        1661     1661           
Flag Coverage Δ
python-3.13 83.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit 8565add into develop Nov 4, 2026
13 checks passed
@ptr727
ptr727 deleted the feature/path-cleanup-keys-3862 branch November 4, 2026 20:04
ptr727 added a commit that referenced this pull request Nov 4, 2026
…upgrade-host.ps1 (#3873)

## Summary

Promotes #3872 and #3874 to `main`.

Closes #3862.

- **#3872** adds `upgrade-host.ps1 -CleanPath`, which removes duplicate,
dead, empty and file-naming entries from the machine and user `Path`.
  - `-Status` lists what it would remove.
- It keeps every kept entry's unexpanded text, order and `REG_EXPAND_SZ`
kind.
- It prints the previous value before writing, and broadcasts the change
after.
  - It writes nothing where either half changed while the prompt waited.
- **Elevation is detected, never required.** Unelevated, it cleans the
user half and names `gsudo` for the machine half. Elevated as the
session's own user, it cleans both.
- **Entries it does not judge are kept and listed.** That covers an
entry under a root that does not answer, one with a variable that does
not expand, and one whose variable changed after the terminal started.
- **#3874** answers this promotion's first Copilot round. A drive root
keeps its separator in the duplicate key, so a bare `C:` is no longer a
repeat of `C:\`. A literal `%` in a directory name no longer leaves the
entry unjudged.
- `menu.ps1` gains entry 6 for the action.
`host-setup/windows/README.md` gains "Cleaning Path".

Verified natively on Windows 11, unelevated and under `gsudo`, with
`-Status` and `-CleanPath -DryRun`. The host's only finding was one
empty user entry, so no live cleanup was run against it. The dead,
duplicate and write paths are covered by `tests/test_upgrade_host.py`,
against a stubbed registry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants