Skip to content

Commit

Permalink
(#23) Move call to SetRemotePackageNamesIfAllSpecified
Browse files Browse the repository at this point in the history
The SetRemotePackageNamesIfAllSpecified method HAS to be called AFTER
the call to GetRemoteRepositories.

In that method, the Sources on the configuration object are expanded to
be the full source URL's, rather than the named sources from the
chocolatey.config file, i.e. https://community.chocolatey.org/api/v2/
rather than simply "chocolatey".

This is important, since the full URL is what is used to ensure that a
"choco install all" is not being attempted against one of the
configured public sources.

This wasn't picked up during the initial PR review, but it was picked
up during manual testing, and this commit is the output of that manual
testing.
  • Loading branch information
gep13 committed Jun 4, 2024
1 parent c74a19c commit 80f86d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,6 @@ public void InstallDryRun(ChocolateyConfiguration config, Action<PackageResult,
_fileSystem.EnsureDirectoryExists(ApplicationParameters.PackagesLocation);
var packageResultsToReturn = new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);

SetRemotePackageNamesIfAllSpecified(config, () => { });

NuGetVersion version = !string.IsNullOrWhiteSpace(config.Version) ? NuGetVersion.Parse(config.Version) : null;
if (config.Force)
{
Expand All @@ -520,6 +518,14 @@ public void InstallDryRun(ChocolateyConfiguration config, Action<PackageResult,

var sourceCacheContext = new ChocolateySourceCacheContext(config);
var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger, _fileSystem);

// The following method HAS to be called AFTER the call to GetRemoteRepositories.
// In that method, the Sources on the configuration object are expanded to be the full source URL's, rather than the named
// sources from the chocolatey.config file, i.e. https://community.chocolatey.org/api/v2/ rather than simply "chocolatey".
// This is important, since the full URL is what is used to ensure that a "choco install all" is not being attempted against
// one of the configured public sources in the following method.
SetRemotePackageNamesIfAllSpecified(config, () => { });

var remoteEndpoints = NugetCommon.GetRepositoryResources(remoteRepositories, sourceCacheContext);
var localRepositorySource = NugetCommon.GetLocalRepository();
var pathResolver = NugetCommon.GetPathResolver(_fileSystem);
Expand Down

0 comments on commit 80f86d5

Please sign in to comment.