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

Rearrange choices for ARP changes #1630

Merged
merged 2 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 9 additions & 30 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,45 +601,24 @@ namespace AppInstaller::CLI::Workflow
// 1 package :: Golden path; this should be what we installed.
// 2+ packages :: The data in the manifest is either too broad or we have
// a problem with our name normalization.
//
// ARP Package changes
// 0 1 N
// +------------------+--------------------+--------------------+
// M | | | |
// a | Package does not | Manifest data does | Manifest data does |
// n 0 | write to ARP | not match ARP | not match ARP |
// i | Log this fact | Log for fixup | Log for fixup |
// f | | | |
// e +------------------+--------------------+--------------------+
// s | | | |
// t | Reinstall of | Golden Path! | Treat manifest as |
// 1 | existing version | (assuming match) | main if common |
// r | | | |
// e +------------------+--------------------+--------------------+
// s | | | |
// u | Not expected | Treat ARP as main | Not expected |
// l N | Log this for | | Log this for |
// t | investigation | | investigation |
// s | | | |
// +------------------+--------------------+--------------------+

// Find the package that we are going to log
std::shared_ptr<IPackageVersion> toLog;

// If no changes found, only log if a single matching package was found by the manifest
if (changes.empty() && findByManifest.Matches.size() == 1)
// If there is only a single common package (changed and matches), it is almost certainly the correct one.
if (packagesInBoth.size() == 1)
{
toLog = findByManifest.Matches[0].Package->GetInstalledVersion();
toLog = packagesInBoth[0]->GetInstalledVersion();
}
// If only a single ARP entry was changed, always log that
else if (changes.size() == 1)
// If it wasn't changed but we still find a match, that is the best thing to report.
else if (findByManifest.Matches.size() == 1)
{
toLog = changes[0].Package->GetInstalledVersion();
toLog = findByManifest.Matches[0].Package->GetInstalledVersion();
}
// Finally, if there is only a single common package, log that one
else if (packagesInBoth.size() == 1)
// If only a single ARP entry was changed and we found no matches, report that.
else if (findByManifest.Matches.empty() && changes.size() == 1)
{
toLog = packagesInBoth[0]->GetInstalledVersion();
toLog = changes[0].Package->GetInstalledVersion();
}

IPackageVersion::Metadata toLogMetadata;
Expand Down
4 changes: 2 additions & 2 deletions src/AppInstallerCLITests/ARPChanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ TEST_CASE("ARPChanges_SingleChange_SingleMatch", "[ARPChanges][workflow]")
context.AddMatchResult("MatchId1", "MatchName1", "MatchPublisher1", "MatchVersion1");

context << ReportARPChanges;
context.ExpectEvent(1, 1, 0, context.EverythingResult.Matches.back().Package.get());
context.ExpectEvent(1, 1, 0, context.MatchResult.Matches.back().Package.get());
}

TEST_CASE("ARPChanges_SingleChange_MultiMatch", "[ARPChanges][workflow]")
Expand Down Expand Up @@ -358,7 +358,7 @@ TEST_CASE("ARPChanges_MultiChange_SingleMatch_NoOverlap", "[ARPChanges][workflow
context.AddMatchResult("MatchId1", "MatchName1", "MatchPublisher1", "MatchVersion1");

context << ReportARPChanges;
context.ExpectEvent(2, 1, 0);
context.ExpectEvent(2, 1, 0, context.MatchResult.Matches.back().Package.get());
}

TEST_CASE("ARPChanges_MultiChange_SingleMatch_Overlap", "[ARPChanges][workflow]")
Expand Down