-
Notifications
You must be signed in to change notification settings - Fork 101
Description
If you have 2 repositories registered, and both of them contain a package Foo, you get an error when you run Install-Module Foo, saying that you have to pick a repository.
It would be better IMHO if this was permitted, and PowerShellGet automatically picked a repository when this happened. The main question is: when 2 repositories contain the requested module, how are ties broken - ie, which one do we pick?
Suggestion:
When Install-Module is run, we find all candidate repositories which contain a matching module, as at present. Then we order them using the method below to pick the preferred repo.
First, trusted vs untrusted is used. All trusted repositories are automatically higher ranked than all untrusted repos.
Second, introduce an explicit ordering for repositories, and a way for users to reorder them. The PSRepositoryInfo flag would have a Priority property added, which would be an int value, with 0 as lowest priority (last to be picked). This can be null, if not explicitly configured, which is treated as 0. Priorities need not be unique or consecutive.
Users can set the Priority property at Register-PSRepository time, and with Set-PSRepository -Priority. If not specified they get 0 priority.
Third, if 2 repositories have the same trust status and the same priority (including null) we pick them in alphabetical order.
Get-PSRepository would display the repos in priority order, NOT the order of the ordered table they are stored in (which is sorted by key). Additionally, it would show the Priority field by default.
This should not be a breaking change, since it only updates behavior for situations which would previously have caused an error.
Questions:
What if a repo with lower priority contains a module with higher version? Should that be taken into account? I think no.
Is it confusing to display an untrusted repo with Priority 999 and a trusted one with priority 1, and then choose the trusted one first?
Should the behavior of any other commands change?
What about package management, any changes needed there?