feat(registry): registry remove command, RegistryManager module & auto-update on init/run#564
Open
OgnjenGligoric wants to merge 9 commits into
Conversation
Introduce a RegistryManager PowerShell module to manage registries.json and auto-update git-based registries (Update-StaleRegistries, Get-DotbotRegistries). The module fetches and fast-forward merges registries (honors auto_update, branch, MaxAgeSecs and skips local symlinked registries), and updates updated_at timestamps. Add registry-remove.ps1 to remove a named registry (deletes local directory or symlink, updates registries.json, and includes user confirmation/force flag). Wire the new RegistryManager into bin/dotbot.ps1 so Invoke-Init and Invoke-Run import the module and call Update-StaleRegistries before proceeding.
Collaborator
|
@OgnjenGligoric do we rely need to bump version to v4.0.1? CC: @carlospedreira |
Collaborator
|
@OgnjenGligoric Is it possible to add some tests for removal? |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the missing “registry remove” deliverable plus a small registry-state helper module, and wires registry auto-update into the main dotbot entrypoint so git-based registries can stay fresh during normal init/run usage.
Changes:
- Introduces
dotbot registry removeto delete a registry’s local cache/link and remove its entry fromregistries.json. - Adds
RegistryManager.psm1withGet-DotbotRegistriesandUpdate-StaleRegistriesfor stale git registry fast-forward updates. - Calls
Update-StaleRegistriesautomatically fromdotbot initanddotbot run.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/cli/RegistryManager.psm1 | New helper module for reading registries + auto-updating stale git registries. |
| src/cli/registry-remove.ps1 | New CLI command to remove a registry from disk and registries.json. |
| bin/dotbot.ps1 | Wires registry auto-update into Invoke-Init and Invoke-Run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Improve error reporting and registry update handling, and harden the registry removal script. Swap generic Write-Warning calls for Write-DotbotWarning and surface JSON parse errors when loading registries.json. Update logic that records updated_at to use UTC timestamps and a safer ForEach-Object update so changes are tracked correctly. Add validation to registry-remove.ps1 to prevent path traversal: validate registry names, resolve full paths, and ensure the target is inside the registries directory, exiting with an error on invalid input.
Contributor
Author
|
@DKuleshov could we do the GitHub Copilot review now? |
Add validation and safety checks when auto-updating registries: sanitize and validate registry names, resolve absolute paths and ensure they remain inside the registries root to prevent path traversal, and require the registry path be an existing container. Suppress git output, check that git exists on PATH before attempting fetch/merge, and update warning messages to use the sanitized name. Also replace a Read-Host confirmation in registry-remove with Read-DotbotConfirmation for a consistent, safer prompt and abort handling.
Contributor
Author
|
@DKuleshov Can we run GitHub Copilot review? |
Contributor
Author
|
@andresharpe Its ready for review. |
Add tests/Test-RegistryCLI.ps1 containing Layer 2 tests for registry-remove.ps1 and RegistryManager.psm1 (Get-DotbotRegistries, Update-StaleRegistries, path-traversal/name validation, removal behavior and registries.json cleanup). Update tests/Run-Tests.ps1 to invoke the new Test-RegistryCLI.ps1 and include its exit code in the layer/overall test results.
Update Test-RegistryCLI.ps1 to run registry-remove tests against the real DOTBOT_HOME/registries instead of a test-only config. Add functions to backup/restore registries.json and to write real registries entries, create a temporary test registry dir with a random name, and assert removal/retention against the real config. Restore original registries.json after each scenario and adjust assertion messages/output variables accordingly.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Closes #550
Summary of changes
Implements three missing deliverables from the Phase 11 enterprise registry feature: a
registry removecommand, aRegistryManagermodule for registry state management, and auto-update of stale git-based registries ondotbot initanddotbot run.New
dotbot registry remove(src/cli/registry-remove.ps1):removes a registry by name — reads
registries.jsonto confirm the registry exists, prompts for confirmation (skippable with-Force), safely removes the local directory or junction/symlink without deleting symlink target contents (detectsReparsePointattribute), then strips the entry fromregistries.json. Mirrors the structure ofregistry-add.ps1.New
RegistryManager.psm1(src/cli/RegistryManager.psm1):module for registry state management, exporting two functions:
Get-DotbotRegistries— reads all entries fromregistries.jsonas an array; returns empty array if file is absent.Update-StaleRegistries— git fetch + fast-forward merge for all git-based registries withauto_update: true; honours aMaxAgeSecsthreshold (default 3600s) to avoid hammering git on every run; failures are non-fatal (warning emitted, stale local copy used); recordsupdated_attimestamp inregistries.jsonon success.Auto-update wired into
bin/dotbot.ps1:both
Invoke-InitandInvoke-Runnow callUpdate-StaleRegistriesbefore executing, so registries stay fresh on normal usage without a manualdotbot registry update.namespace:stackresolution ininit-project.ps1: already implemented —Resolve-FrameworkSourcehandlesnamespace:namefor bothworkflowsandstacksvia the same code path. No change needed.Testing notes
Manual inspection confirms the routing for
dotbot registry removewas already wired inbin/dotbot.ps1(Invoke-Registryswitch). The remove script follows the same validation and output patterns as the existing registry commands.Checklist