Skip to content

Conversation

@Nigusu-Allehu
Copy link
Member

@Nigusu-Allehu Nigusu-Allehu commented Nov 18, 2025

Bug

Fixes: https://github.com/NuGet/NuGet.Client/pull/6885/files#r2487713673
Fixes: #6885 (comment)

Description

This PR Factorizes the PackageDownloadRunner.TryGetRepositoriesForPackage method, to improve readability. In addition, it adds one more test scenario for the package download command: " no --source, mapping -> A&B, package in both A and B. Latest version from A installed". In addition, it also addresses a bug where http source validation was not being done for package sources when source mapping is enabled and the package is not mapped to any of the sources.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@Nigusu-Allehu Nigusu-Allehu self-assigned this Nov 18, 2025
@Nigusu-Allehu Nigusu-Allehu marked this pull request as ready for review November 18, 2025 21:10
@Nigusu-Allehu Nigusu-Allehu requested a review from a team as a code owner November 18, 2025 21:10
@Nigusu-Allehu Nigusu-Allehu force-pushed the dev-nyenework-factorize branch from 14ae511 to fdc157e Compare November 19, 2025 01:10
jeffkl
jeffkl previously approved these changes Nov 19, 2025
zivkan
zivkan previously approved these changes Nov 19, 2025
@aortiz-msft
Copy link
Contributor

@Nigusu-Allehu - How does this implementation differ now from the Restore code path? Any chance of refactoring into a common function?

cc @nkolev92

@Nigusu-Allehu
Copy link
Member Author

@Nigusu-Allehu - How does this implementation differ now from the Restore code path? Any chance of refactoring into a common function?

cc @nkolev92

Oh yes, a refactoring would definitely be nice. One question I had while looking at this: since both restore's remote walker and this command already share the core mapping logic through PackageSourceMapping.GetConfiguredPackageSources(...), do you think there’s much common code left to factor out?

After that call, each path just converts source names into its own representation (IRemoteDependencyProvider in the remote walker vs SourceRepository here)

Curious what others think. happy to adjust if you see a clean way to unify those parts.

@nkolev92
Copy link
Member

After that call, each path just converts source names into its own representation (IRemoteDependencyProvider in the remote walker vs SourceRepository here)

Yeah, unfortunately any refactoring would probably add complexity, since it'd probably need to use Func or something to choose the comparer and that just adds allocations.

@aortiz-msft
Copy link
Contributor

aortiz-msft commented Nov 20, 2025

Any tests from the restore implementation that we can copy over or viceversa?


In reply to: 3554996830

Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@Nigusu-Allehu Nigusu-Allehu dismissed stale reviews from zivkan and jeffkl via 7bd2e43 November 20, 2025 18:19
@Nigusu-Allehu
Copy link
Member Author

Any tests from the restore implementation that we can copy over or viceversa?

In reply to: 3554996830

Missing in PackageDownloadRunnerTests vs FilterDependencyProvidersForLibraryTests:

  • Case-insensitive matching of source names (Added)

Missing in FilterDependencyProvidersForLibraryTests vs PackageDownloadRunnerTests :

  • Package pattern mapped to multiple sources all applicable providers returned.

  • Mapping includes a source name that doesn’t exist in the provider list

nkolev92
nkolev92 previously approved these changes Nov 20, 2025
@nkolev92 nkolev92 dismissed their stale review November 20, 2025 19:41

sorry, bad click, I meant to comment.

@Nigusu-Allehu Nigusu-Allehu force-pushed the dev-nyenework-factorize branch from f3999ed to 62c2dfa Compare November 21, 2025 02:01
@aortiz-msft
Copy link
Contributor

Missing in FilterDependencyProvidersForLibraryTests vs PackageDownloadRunnerTests :

  • Package pattern mapped to multiple sources all applicable providers returned.
  • Mapping includes a source name that doesn’t exist in the provider list

I'm not seeing tests added to FilterDependencyProvidersForLibraryTests. Could you please add the appropriate tests there as well as part of this PR?

@aortiz-msft aortiz-msft reopened this Nov 24, 2025
Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@Nigusu-Allehu
Copy link
Member Author

Missing in FilterDependencyProvidersForLibraryTests vs PackageDownloadRunnerTests :

  • Package pattern mapped to multiple sources all applicable providers returned.
  • Mapping includes a source name that doesn’t exist in the provider list

I'm not seeing tests added to FilterDependencyProvidersForLibraryTests. Could you please add the appropriate tests there as well as part of this PR?

As discussed, offline, added here instead of a separate follow up pr.

Copy link
Contributor

@aortiz-msft aortiz-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for now, but refactoring to be done in a separate PR.

@Nigusu-Allehu Nigusu-Allehu merged commit 11ea99e into dev Nov 25, 2025
17 of 18 checks passed
@Nigusu-Allehu Nigusu-Allehu deleted the dev-nyenework-factorize branch November 25, 2025 01:05
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.

6 participants