Skip to content

chore(pwsh): dedup git helpers + drop dead psmux scripts (#129)#131

Merged
Gerrrt merged 3 commits into
mainfrom
chore/dedup-deadcode-129
Jul 18, 2026
Merged

chore(pwsh): dedup git helpers + drop dead psmux scripts (#129)#131
Gerrrt merged 3 commits into
mainfrom
chore/dedup-deadcode-129

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Picks up the dedup cleanups (C2–C4) and dead-code removal from #129. Pure hygiene, low risk. Verified on the Windows host with Invoke-Pester (578 passing).

Changes

C2 / C3 — one shared git-revision resolver. Extracted Get-DotRepoRevision (short SHA + commit date + dirty flag) into os/45-doctor.ps1 and shared it across three call sites that each open-coded the same git log/git status block: the doctor's "Repo version" row, the doctor report header, and the core-version verb (os/48-core.ps1).

This also fixes a latent display bug: the header re-derived the SHA behind an if ($root …) guard, but $root there was a local of the other function (Get-DoctorResults), so it was always $null — the header silently printed dotfiles-Windows dev instead of the revision, and the git rev-parse inside never even ran. Threading the pre-resolved revision through Get-DoctorResults means the row and header share one git spawn (was three across the two), and the header now shows the real short SHA:

dotfiles-Windows b2bc408 — core-doctor (✓ ok · ! warn · ✗ fail)

C4 — one shared branch lister. Factored the identical branch-clean pipeline in fbr (core/20-functions.ps1) and tbranch (core/25-television.ps1) into Get-DotGitBranchNames.

Dead code. Removed psmux/scripts/psmux-cpu.ps1 and psmux/scripts/psmux-netspeed.ps1 — vestigial after the psmux bar was de-pwsh'd; no live #() reference in psmux.conf (its comments already document them as intentionally gone).

Verification

  • Full suite: 578 passed, 0 failed (count is −4 vs main only because a per-file test enumerated the two deleted scripts).
  • Runtime: confirmed the doctor header, "Repo version" row, and core-version now all report the same real SHA; Get-DotGitBranchNames lists cleaned refs.
  • Load-contract provides/requires headers updated; Core.Tests.ps1 stubs Get-DotRepoRevision (mirroring its existing Test-Cmd stub) since it dot-sources 48-core in isolation.

Part of #129; the security/packaging tail is a separate follow-up PR.

🤖 Generated with Claude Code

Deferred hygiene items from the 2026-07-17 triage. Verified with
Invoke-Pester (578 passing).

C2/C3 — extract Get-DotRepoRevision (short SHA + commit date + dirty) into
os/45-doctor.ps1 and share it across the doctor's "Repo version" row, the
doctor header, and the `core-version` verb (os/48-core.ps1). This also fixes
a latent bug: the header re-derived the SHA behind an `if ($root …)` guard
whose $root was a local of the OTHER function (Get-DoctorResults), so it was
always $null and the header silently printed "dev" instead of the revision.
Threading the pre-resolved revision through Get-DoctorResults means one git
spawn shared by row + header (was three), and the header now shows the real
short SHA.

C4 — factor the branch-clean pipeline shared by fbr (core/20-functions.ps1)
and tbranch (core/25-television.ps1) into Get-DotGitBranchNames.

Dead code — remove psmux/scripts/psmux-cpu.ps1 and psmux-netspeed.ps1;
vestigial after the bar was de-pwsh'd, no live #() in psmux.conf (the conf
comments already document them as intentionally gone).

Also update the load-contract provides/requires headers and Core.Tests.ps1
(stub Get-DotRepoRevision, mirroring the existing Test-Cmd stub, since the
front-door test dot-sources 48-core in isolation).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSeBsL1YesMCpEqxHXSKkv
Copilot AI review requested due to automatic review settings July 17, 2026 23:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Deduplicates PowerShell git-helper logic by centralizing repo revision resolution and branch-name listing, and removes vestigial psmux status scripts that are no longer referenced—keeping the Windows host layer tidy and consistent across related verbs.

Changes:

  • Extract Get-DotRepoRevision into powershell/os/45-doctor.ps1 and reuse it in dotfiles-doctor and core-version to avoid repeated git spawning.
  • Factor branch listing/cleanup into Get-DotGitBranchNames and reuse it in fbr and tbranch.
  • Remove dead psmux PowerShell scripts (psmux-cpu.ps1, psmux-netspeed.ps1) and update Core.Tests.ps1 to stub the new fragment helper.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Core.Tests.ps1 Stubs Get-DotRepoRevision for isolated dot-sourcing of os/48-core.ps1 in tests.
psmux/scripts/psmux-netspeed.ps1 Deleted vestigial status-segment script.
psmux/scripts/psmux-cpu.ps1 Deleted vestigial status-segment script.
powershell/os/48-core.ps1 Uses shared Get-DotRepoRevision for core-version output and updates load contract header.
powershell/os/45-doctor.ps1 Adds Get-DotRepoRevision and threads resolved revision through results + header to dedup git calls.
powershell/core/25-television.ps1 Switches tbranch to use shared branch-name helper and updates load contract header.
powershell/core/20-functions.ps1 Introduces Get-DotGitBranchNames and updates fbr to use it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread powershell/os/45-doctor.ps1 Outdated
# revision is resolved by the caller and passed in (so the header can reuse the
# same object without a second git spawn — C2); fall back to resolving it here
# when called directly with no -RepoRevision.
$rev = if ($PSBoundParameters.ContainsKey('RepoRevision')) { $RepoRevision } else { Get-DotRepoRevision -Root $root }

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.

Fixed in the latest commit. Gate the fallback on $null instead of $PSBoundParameters.ContainsKey, so a caller passing -RepoRevision $null (dotfiles-doctor, on a non-git checkout) re-resolves as documented — correct and cheap, since Get-DotRepoRevision fails fast on the .git check (no git spawn).

Addresses Copilot review: Get-DoctorResults treated `-RepoRevision $null` as
"provided" and skipped the documented fallback, making behaviour depend on
whether callers pass the parameter at all. Gate the fallback on $null instead —
a caller passing $null (dotfiles-doctor, on a non-git checkout) genuinely has no
revision, so re-resolving is correct and cheap (Get-DotRepoRevision fails fast on
the .git check, no git spawn).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSeBsL1YesMCpEqxHXSKkv

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment on lines 357 to 360
Write-DotHost ' re-checking...' -Color Cyan
$results = Get-DoctorResults
$results = Get-DoctorResults -RepoRevision $rev
$s = Get-DoctorSummary $results
$color = switch ($s.Overall) { 'ok' { 'Green' } 'warn' { 'Yellow' } 'fail' { 'Red' } }

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.

Fixed. The -Fix re-check now calls Get-DotRepoRevision -Root $root again before re-running Get-DoctorResults, so the second 'Repo version' row reflects post-fix state. (Today's fix actions all act outside the repo tree — registry, $HOME symlinks, LOCALAPPDATA modules, package installs — so it's defensive, but it keeps the re-check honest.)

Addresses Copilot review: the -Fix re-check reused the pre-fix $rev, so if a
fix action touched the working tree the second "Repo version" row could show a
stale dirty flag/date. Re-resolve via Get-DotRepoRevision before re-running
Get-DoctorResults. Today's fixes all act outside the repo (registry, $HOME
symlinks, LOCALAPPDATA modules, package installs), so it's defensive — but it
keeps the re-check honest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSeBsL1YesMCpEqxHXSKkv
@Gerrrt
Gerrrt merged commit af06e60 into main Jul 18, 2026
6 checks passed
@Gerrrt
Gerrrt deleted the chore/dedup-deadcode-129 branch July 18, 2026 02:03
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.

2 participants