Fix/install arg normalization - #283
Open
Spelt wants to merge 2 commits into
Open
Conversation
…y normalized name "boss install https://host/owner/repo" reported "No dependencies to install" and saved nothing. EnsureDependency strips the protocol prefix when it stores the key in boss.json (parseURLAndVersion's regex consumes it), but collectDependenciesToInstall compared boss.json keys against ParseDependency(arg), which keeps the prefix. The two never matched for a protocol-prefixed argument, so the requested dependency was filtered out and DoInstall returned before saving the package. Compare through the existing Dependency.Name() normalization instead (protocol, credentials and .git suffix ignored, case-insensitive), via a new domain.RepositoryName helper: - collectDependenciesToInstall and the requestedDeps filter in the install context now match by normalized name. - Package.AddDependency and Package.UninstallDependency match existing keys by normalized name too, so a protocol-prefixed argument updates or removes the bare key (and vice versa) instead of creating a duplicate entry or silently missing it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
"boss install https://host/owner/repo:1.2.3" still reported "No dependencies to install": the argument was normalized including the ":1.2.3" suffix (Dependency.Name() turns the colon into a path separator), while the stored key has the version stripped. Normalize through parseURLAndVersion first — new requestedDependencyName helper used by collectDependenciesToInstall and the requestedDeps filter — and strip the version suffix in UninstallModules before matching, so ":version" and "@Version" arguments resolve to the same key as their plain counterparts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Problem
Installing a dependency by its full URL like https://github.com/Me/MyProject:13.1.20 does nothing:
Nothing is installed and
boss.jsonis not updated.Cause:
EnsureDependencystores the dependency key inboss.jsonwithout the protocol prefix (parseURLAndVersion's regex consumeshttps://), butcollectDependenciesToInstallcompares the stored keys againstParseDependency(arg), which keeps the prefix. For a protocol-prefixed argument the two never match, so the requested dependency is filtered out andDoInstallreturns before saving the package. Projects whoseboss.jsonstill contains protocol-prefixed keys written by older Boss versions were masking this; after aboss remove+boss installcycle the new bare key no longer matches.Fix
Compare through the existing
Dependency.Name()normalization (protocol, credentials and.gitsuffix ignored, case-insensitive), exposed as a newdomain.RepositoryNamehelper:collectDependenciesToInstalland therequestedDepsfilter in the install context match by normalized name.Package.AddDependency/Package.UninstallDependencyalso match existing keys by normalized name, so a protocol-prefixed argument updates or removes a bare key (and vice versa) instead of creating a duplicate entry or silently missing it.The same mismatch existed for version-suffixed arguments (
boss install https://host/owner/repo:1.2.3): the suffix ended up inside the normalized name. Arguments are now normalized throughparseURLAndVersionfirst (requestedDependencyNamehelper), andUninstallModulesstrips the version suffix before matching, so:version/@versionarguments resolve to the same key as their plain counterparts.Testing
go build ./...,go vetclean;go test ./internal/core/...passesinstall <https-url>→ "No dependencies to install",boss.jsonunchanged); with this patchboss remove <https-url>followed byboss install <https-url>adds the dependency toboss.jsonand installs the moduleboss install https://github.com/viniciussanchez/dataset-serialize:2.5.9stores"github.com/viniciussanchez/dataset-serialize": "2.5.9"and installs the module;boss removewith the same suffixed argument removes the entry