Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure top-level package isn't duplicated in new source mappings #5374

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ internal static void ConfigureNewPackageSourceMapping(
PackageSourceMapping packageSourceMapping = new(patternsReadOnly);

// Expand all patterns/globs so we can later check if this package ID was already mapped.
List<string> addedPackageIdsWithoutExistingMappings = new();
List<string> addedPackageIdsWithoutExistingMappings = new(capacity: addedPackageIds.Count + 1);
bool topLevelPackageIdWasAdded = false;
foreach (string addedPackageId in addedPackageIds)
{
topLevelPackageIdWasAdded = topLevelPackageIdWasAdded || addedPackageId == userAction.PackageId;
IReadOnlyList<string> configuredSource = packageSourceMapping.GetConfiguredPackageSources(addedPackageId);
if (configuredSource.Count == 0)
{
Expand All @@ -41,9 +43,12 @@ internal static void ConfigureNewPackageSourceMapping(

// Get all newly added package IDs that were not previously Source Mapped.
// Always include the Package ID being installed since it takes precedence over any globbing.
string[] packageIdsNeedingNewSourceMappings = addedPackageIdsWithoutExistingMappings
.Append(userAction.PackageId)
.ToArray();
if (!topLevelPackageIdWasAdded)
{
addedPackageIdsWithoutExistingMappings.Add(userAction.PackageId);
}

string[] packageIdsNeedingNewSourceMappings = addedPackageIdsWithoutExistingMappings.ToArray();
donnie-msft marked this conversation as resolved.
Show resolved Hide resolved

CreateAndSavePackageSourceMappings(
userAction.SourceMappingSourceName,
Expand Down