Skip to content

[#236] Extract shared artifact-removal helpers#243

Merged
bguidolim merged 2 commits intomainfrom
feature/236-artifact-removal-helpers
Mar 6, 2026
Merged

[#236] Extract shared artifact-removal helpers#243
bguidolim merged 2 commits intomainfrom
feature/236-artifact-removal-helpers

Conversation

@bguidolim
Copy link
Owner

Summary

Extracts per-artifact-type removal helpers from Configurator.swift to reduce duplication across unconfigurePack(), removeNewlyExcludedComponentArtifacts(), and reconcileStaleArtifacts(). Pure internal refactor — no behavioral changes.

Closes #236

Changes

  • Add RefCountedRemovalResult enum (.removed, .stillNeeded, .failed) for 3-way brew/plugin removal semantics
  • Add 5 private helpers: removeMCPServerArtifact, removeFileArtifactItem, removeBrewArtifact, removePluginArtifact, removeGitignoreArtifact
  • Refactor all 3 artifact-removal methods to delegate to shared helpers, eliminating ~70 lines of duplicated ref-counting, do/catch, and removal logic

Test plan

  • swift test passes locally (4 unrelated PackFetcherTests failures from 1Password SSH agent)
  • swiftformat --lint . and swiftlint pass without violations
  • Affected commands verified with a real pack (e.g. mcs sync, mcs doctor)
Checklist for engine changes

Only check items that apply to this PR. Delete irrelevant ones.

  • N/A — pure refactor, no new paths, state changes, or behavior changes

- Add RefCountedRemovalResult enum and 5 private helpers (removeMCPServerArtifact, removeFileArtifactItem, removeBrewArtifact, removePluginArtifact, removeGitignoreArtifact)
- Refactor unconfigurePack, removeNewlyExcludedComponentArtifacts, and reconcileStaleArtifacts to use shared helpers
- Centralize ref-counting logic for brew/plugins and do/catch for gitignore entries
- Reword stillNeeded case doc to describe state, not prescribe caller behavior
- Replace "Callers handle success/failure logging" with neutral wording
- Add inline comment in reconcileStaleArtifacts gitignore else branch
@bguidolim bguidolim merged commit eef6ca7 into main Mar 6, 2026
4 checks passed
@bguidolim bguidolim deleted the feature/236-artifact-removal-helpers branch March 6, 2026 09:01
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.

Extract shared artifact-removal helpers to reduce duplication in Configurator

1 participant