Skip to content
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
35 changes: 35 additions & 0 deletions src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ await this.UpdateManifestsInteractively(initialManifests) :
return false;
}

if (!this.Replace)
{
// Updated manifests will always be in multi-manifest format so no need to check for singleton manifest.
string updatedVersion = updatedManifests.VersionManifest.PackageVersion;
string originalVersion = originalManifests.VersionManifest != null ? originalManifests.VersionManifest.PackageVersion : originalManifests.SingletonManifest.PackageVersion;

if (WinGetUtil.CompareVersions(updatedVersion, originalVersion) != 0 && AreInstallerUrlsVanityUrls(originalManifests, updatedManifests))
{
Logger.InfoLocalized(nameof(Resources.AutoReplacingPreviousVersion_Message));
Console.WriteLine();
this.Replace = true;
}
}

return await this.LoadGitHubClient(true)
? (commandEvent.IsSuccessful = await this.GitHubSubmitManifests(
updatedManifests,
Expand Down Expand Up @@ -638,6 +652,27 @@ private static void DisplayManifestsAsMenuSelection(Manifests manifests)
}
}

private static bool AreInstallerUrlsVanityUrls(Manifests baseManifest, Manifests newManifest)
{
List<Installer> newInstallers = newManifest.InstallerManifest.Installers;

// All installer URLs in the new manifest must have a matching installer URL in the base manifest.
foreach (Installer installer in newInstallers)
{
if (baseManifest.InstallerManifest != null && !baseManifest.InstallerManifest.Installers.Any(i => i.InstallerUrl == installer.InstallerUrl))
{
return false;
}

if (baseManifest.SingletonManifest != null && !baseManifest.SingletonManifest.Installers.Any(i => i.InstallerUrl == installer.InstallerUrl))
{
return false;
}
}

return true;
}

private string ObtainMatchingRelativeFilePath(string oldRelativeFilePath, string directory, string archiveName)
{
string fileName = Path.GetFileName(oldRelativeFilePath);
Expand Down
9 changes: 9 additions & 0 deletions src/WingetCreateCLI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,4 +1118,7 @@
<data name="UseOverrides_ErrorMessage" xml:space="preserve">
<value>Try using the architecture and/or scope overrides to uniquely match new URLs to existing installer nodes in the manifest.</value>
</data>
<data name="AutoReplacingPreviousVersion_Message" xml:space="preserve">
<value>Vanity URL detected. The submission will automatically replace the previous version.</value>
</data>
</root>