diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index ed241fb0..1668e1b3 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -138,6 +138,7 @@ 720AC2DC2618E8A500E25A3E /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; }; 720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; }; 720DC50427A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml in Resources */ = {isa = PBXBuildFile; fileRef = 720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */; }; + 720DC50627A62CDC00DFF3EC /* testappcast_minimumAutoupdateVersionSkipping2.xml in Resources */ = {isa = PBXBuildFile; fileRef = 720DC50527A62CDC00DFF3EC /* testappcast_minimumAutoupdateVersionSkipping2.xml */; }; 720E217B1D0D00BF003A311C /* SPUUpdaterCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */; }; 720E217C1D0D00BF003A311C /* SPUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */; }; 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; }; @@ -975,6 +976,7 @@ 720B4C2325EBFAFD005A0592 /* link-tools.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "link-tools.sh"; sourceTree = ""; }; 720C192827127A3800740C8E /* release-move-tag.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "release-move-tag.sh"; sourceTree = ""; }; 720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testappcast_minimumAutoupdateVersionSkipping.xml; sourceTree = ""; }; + 720DC50527A62CDC00DFF3EC /* testappcast_minimumAutoupdateVersionSkipping2.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testappcast_minimumAutoupdateVersionSkipping2.xml; sourceTree = ""; }; 720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdaterCycle.h; sourceTree = ""; }; 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUpdaterCycle.m; sourceTree = ""; }; 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = ""; }; @@ -1767,6 +1769,7 @@ 723EDC3E26885A8E000BCBA4 /* testappcast_channels.xml */, 725B3A81263FBF0C0041AB8E /* testappcast_minimumAutoupdateVersion.xml */, 720DC50327A51A6500DFF3EC /* testappcast_minimumAutoupdateVersionSkipping.xml */, + 720DC50527A62CDC00DFF3EC /* testappcast_minimumAutoupdateVersionSkipping2.xml */, 7202DC99269ABD3500737EC4 /* testappcast_phasedRollout.xml */, 722545B526805FF80036465C /* testappcast_info_updates.xml */, 5F1510A11C96E591006E1629 /* testnamespaces.xml */, @@ -3053,6 +3056,7 @@ 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, 5AF6C74F1AEA46D10014A3AB /* test.pkg in Resources */, 72BC6C3D275027BF0083F14B /* SparkleTestCodeSign_apfs.dmg in Resources */, + 720DC50627A62CDC00DFF3EC /* testappcast_minimumAutoupdateVersionSkipping2.xml in Resources */, 5AD0FA7F1C73F2E2004BCEFF /* testappcast.xml in Resources */, FA30773D24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml in Resources */, 72CCDEBE27421FD500B53718 /* SparkleTestCodeSignApp_bad_header.zip in Resources */, diff --git a/Sparkle/Base.lproj/Sparkle.strings b/Sparkle/Base.lproj/Sparkle.strings index f1494d81..2ed8e62e 100644 --- a/Sparkle/Base.lproj/Sparkle.strings +++ b/Sparkle/Base.lproj/Sparkle.strings @@ -95,9 +95,6 @@ /* Title confirmation for skipping major upgrade and future updates */ "Are you sure you want to skip this upgrade?" = "Are you sure you want to skip this upgrade?"; -/* Confirmation message for skipping major upgrade and future updates */ -"Skipping this major upgrade will opt out of alerts for future updates." = "Skipping this major upgrade will opt out of alerts for future updates."; - /* Skipping major upgrade */ "Skip Upgrade" = "Skip Upgrade"; diff --git a/Sparkle/SPUSkippedUpdate.h b/Sparkle/SPUSkippedUpdate.h index ebf44aad..d88f24db 100644 --- a/Sparkle/SPUSkippedUpdate.h +++ b/Sparkle/SPUSkippedUpdate.h @@ -27,12 +27,14 @@ NS_ASSUME_NONNULL_BEGIN + (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host; // At least one of minorVersion or majorVersion should be non-nil -- (instancetype)initWithMinorVersion:(nullable NSString *)minorVersion majorVersion:(nullable NSString *)majorVersion; +- (instancetype)initWithMinorVersion:(nullable NSString *)minorVersion majorVersion:(nullable NSString *)majorVersion majorSubreleaseVersion:(nullable NSString *)majorSubreleaseVersion; -// At least one of these version properties will be non-nil +// At least one of these two version properties will be non-nil @property (nonatomic, readonly, nullable) NSString *minorVersion; @property (nonatomic, readonly, nullable) NSString *majorVersion; +@property (nonatomic, readonly, nullable) NSString *majorSubreleaseVersion; + @end NS_ASSUME_NONNULL_END diff --git a/Sparkle/SPUSkippedUpdate.m b/Sparkle/SPUSkippedUpdate.m index c3d61bed..af63ad2d 100644 --- a/Sparkle/SPUSkippedUpdate.m +++ b/Sparkle/SPUSkippedUpdate.m @@ -18,13 +18,15 @@ @synthesize minorVersion = _minorVersion; @synthesize majorVersion = _majorVersion; +@synthesize majorSubreleaseVersion = _majorSubreleaseVersion; -- (instancetype)initWithMinorVersion:(nullable NSString *)minorVersion majorVersion:(nullable NSString *)majorVersion +- (instancetype)initWithMinorVersion:(nullable NSString *)minorVersion majorVersion:(nullable NSString *)majorVersion majorSubreleaseVersion:(nullable NSString *)majorSubreleaseVersion { self = [super init]; if (self != nil) { _minorVersion = [minorVersion copy]; _majorVersion = [majorVersion copy]; + _majorSubreleaseVersion = [majorSubreleaseVersion copy]; assert(_minorVersion != nil || _majorVersion != nil); } @@ -35,9 +37,10 @@ { NSString *minorVersion = [host objectForUserDefaultsKey:SUSkippedMinorVersionKey]; NSString *majorVersion = [host objectForUserDefaultsKey:SUSkippedMajorVersionKey]; + NSString *majorSubreleaseVersion = [host objectForUserDefaultsKey:SUSkippedMajorSubreleaseVersionKey]; if (minorVersion != nil || majorVersion != nil) { - return [[SPUSkippedUpdate alloc] initWithMinorVersion:minorVersion majorVersion:majorVersion]; + return [[SPUSkippedUpdate alloc] initWithMinorVersion:minorVersion majorVersion:majorVersion majorSubreleaseVersion:majorSubreleaseVersion]; } else { return nil; } @@ -47,17 +50,20 @@ { [host setObject:nil forUserDefaultsKey:SUSkippedMinorVersionKey]; [host setObject:nil forUserDefaultsKey:SUSkippedMajorVersionKey]; + [host setObject:nil forUserDefaultsKey:SUSkippedMajorSubreleaseVersionKey]; } + (void)skipUpdate:(SUAppcastItem *)updateItem host:(SUHost *)host { + NSString *version = updateItem.versionString; + if (updateItem.majorUpgrade) { NSString *majorVersion = updateItem.minimumAutoupdateVersion; assert(majorVersion != nil); [host setObject:majorVersion forUserDefaultsKey:SUSkippedMajorVersionKey]; + [host setObject:version forUserDefaultsKey:SUSkippedMajorSubreleaseVersionKey]; } else { - NSString *version = updateItem.versionString; [host setObject:version forUserDefaultsKey:SUSkippedMinorVersionKey]; } } diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index d17c0098..dae8b896 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -85,7 +85,7 @@ SU_EXPORT @protocol SPUUserDriver * If the state.stage is `SPUUserUpdateStateInstalling`, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated. * * A reply of `SPUUserUpdateChoiceSkip` skips this particular version and won't notify the user again, unless they initiate an update check themselves. - * If @c appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped. + * If @c appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped, unless a future minor update specifies a `` requirement. * If the state.stage is `SPUUpdateStateInstalling`, the installation is also canceled when the update is skipped. * * @param appcastItem The Appcast Item containing information that reflects the new update. diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 7e6d6ccf..3b52c058 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -334,9 +334,12 @@ + (BOOL)item:(SUAppcastItem *)ui containsSkippedUpdate:(SPUSkippedUpdate * _Nullable)skippedUpdate hostPassesSkippedMajorVersion:(BOOL)hostPassesSkippedMajorVersion versionComparator:(id)versionComparator { NSString *skippedMajorVersion = skippedUpdate.majorVersion; + NSString *skippedMajorSubreleaseVersion = skippedUpdate.majorSubreleaseVersion; - if (!hostPassesSkippedMajorVersion && skippedMajorVersion != nil && ui.minimumAutoupdateVersion != nil && [versionComparator compareVersion:skippedMajorVersion toVersion:(NSString * _Nonnull)ui.minimumAutoupdateVersion] != NSOrderedAscending) { + if (!hostPassesSkippedMajorVersion && skippedMajorVersion != nil && ui.minimumAutoupdateVersion != nil && [versionComparator compareVersion:skippedMajorVersion toVersion:(NSString * _Nonnull)ui.minimumAutoupdateVersion] != NSOrderedAscending && (ui.ignoreSkippedUpgradesBelowVersion == nil || (skippedMajorSubreleaseVersion != nil && [versionComparator compareVersion:skippedMajorSubreleaseVersion toVersion:(NSString * _Nonnull)ui.ignoreSkippedUpgradesBelowVersion] != NSOrderedAscending))) { // If skipped major version is >= than the item's minimumAutoupdateVersion, we can skip the item. + // But if there is an ignoreSkippedUpgradesBelowVersion, we can only skip the item if the last skipped subrelease + // version is >= than that version provided by the item return YES; } diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index 46815851..f816ac35 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -265,9 +265,11 @@ SU_EXPORT @interface SUAppcastItem : NSObject Otherwise if the requirement is not met, the user is always prompted to install the update. In this case, the update is assumed to be a `majorUpgrade`. - If the update is a `majorUpgrade` and the update is skipped by the user, other future update alerts with the same `minimumAutoupdateVersion` will also be skipped. + If the update is a `majorUpgrade` and the update is skipped by the user, other future update alerts with the same `minimumAutoupdateVersion` will also be skipped automatically unless an update specifies `ignoreSkippedUpgradesBelowVersion`. This version string corresponds to the application's @c CFBundleVersion + + This is extracted from the @c element. */ @property (copy, readonly, nullable) NSString *minimumAutoupdateVersion; @@ -278,6 +280,19 @@ SU_EXPORT @interface SUAppcastItem : NSObject */ @property (getter=isMajorUpgrade, readonly) BOOL majorUpgrade; +/** + Previously skipped upgrades by the user will be ignored if they skipped an update whose version precedes this version. + + This can only be applied if the update is a `majorUpgrade`. + + This version string corresponds to the application's @c CFBundleVersion + + This is extracted from the @c element. + + Old applications must be using Sparkle 2.1 or later, otherwise this property will be ignored. + */ +@property (nonatomic, readonly, nullable) NSString *ignoreSkippedUpgradesBelowVersion; + /** Indicates whether or not the update item is critical. diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 63c5ef28..0d850d7f 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -73,6 +73,7 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; @synthesize propertiesDictionary = _propertiesDictionary; @synthesize installationType = _installationType; @synthesize minimumAutoupdateVersion = _minimumAutoupdateVersion; +@synthesize ignoreSkippedUpgradesBelowVersion = _ignoreSkippedUpgradesBelowVersion; @synthesize phasedRolloutInterval = _phasedRolloutInterval; @synthesize state = _state; @synthesize hasCriticalInformation = _hasCriticalInformation; @@ -115,6 +116,7 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; _maximumSystemVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMaximumSystemVersionKey] copy]; _minimumSystemVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMinimumSystemVersionKey] copy]; _minimumAutoupdateVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastElementMinimumAutoupdateVersion] copy]; + _ignoreSkippedUpgradesBelowVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastElementIgnoreSkippedUpgradesBelowVersion] copy]; _releaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemReleaseNotesURLKey]; _fullReleaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemFullReleaseNotesURLKey]; _title = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemTitleKey] copy]; @@ -183,6 +185,10 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; [encoder encodeObject:self.minimumAutoupdateVersion forKey:SUAppcastElementMinimumAutoupdateVersion]; } + if (self.ignoreSkippedUpgradesBelowVersion != nil) { + [encoder encodeObject:self.ignoreSkippedUpgradesBelowVersion forKey:SUAppcastElementIgnoreSkippedUpgradesBelowVersion]; + } + if (self.state != nil) { [encoder encodeObject:self.state forKey:SUAppcastItemStateKey]; } @@ -463,6 +469,8 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState"; _maximumSystemVersion = [(NSString *)[dict objectForKey:SUAppcastElementMaximumSystemVersion] copy]; _minimumAutoupdateVersion = [(NSString *)[dict objectForKey:SUAppcastElementMinimumAutoupdateVersion] copy]; + _ignoreSkippedUpgradesBelowVersion = [(NSString *)[dict objectForKey:SUAppcastElementIgnoreSkippedUpgradesBelowVersion] copy]; + NSString *channel = [dict objectForKey:SUAppcastElementChannel]; if (channel != nil) { if (channel.length == 0) { diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index 1748d3e8..bb012583 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -42,6 +42,7 @@ extern NSString *const SURelaunchHostBundleKey; extern NSString *const SUShowReleaseNotesKey; extern NSString *const SUSkippedMinorVersionKey; extern NSString *const SUSkippedMajorVersionKey; +extern NSString *const SUSkippedMajorSubreleaseVersionKey; extern NSString *const SUScheduledCheckIntervalKey; extern NSString *const SULastCheckTimeKey; extern NSString *const SUExpectsDSASignatureKey; @@ -95,6 +96,7 @@ extern NSString *const SUAppcastElementPhasedRolloutInterval; extern NSString *const SUAppcastElementInformationalUpdate; extern NSString *const SUAppcastElementChannel; extern NSString *const SUAppcastElementBelowVersion; +extern NSString *const SUAppcastElementIgnoreSkippedUpgradesBelowVersion; extern NSString *const SURSSAttributeURL; extern NSString *const SURSSAttributeLength; diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index fa5c1124..466e7d50 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -38,6 +38,7 @@ NSString *const SURelaunchHostBundleKey = @"SURelaunchHostBundle"; NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes"; NSString *const SUSkippedMinorVersionKey = @"SUSkippedVersion"; NSString *const SUSkippedMajorVersionKey = @"SUSkippedMajorVersion"; +NSString *const SUSkippedMajorSubreleaseVersionKey = @"SUSkippedMajorSubreleaseVersion"; NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval"; NSString *const SULastCheckTimeKey = @"SULastCheckTime"; NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature"; @@ -92,6 +93,7 @@ NSString *const SUAppcastElementPhasedRolloutInterval = @"sparkle:phasedRolloutI NSString *const SUAppcastElementInformationalUpdate = @"sparkle:informationalUpdate"; NSString *const SUAppcastElementChannel = @"sparkle:channel"; NSString *const SUAppcastElementBelowVersion = @"sparkle:belowVersion"; +NSString *const SUAppcastElementIgnoreSkippedUpgradesBelowVersion = @"sparkle:ignoreSkippedUpgradesBelowVersion"; NSString *const SURSSAttributeURL = @"url"; NSString *const SURSSAttributeLength = @"length"; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index afe650b1..f88f114a 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -141,23 +141,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE - (IBAction)skipThisVersion:(id)__unused sender { - if (self.updateItem.majorUpgrade) { - NSAlert *alert = [[NSAlert alloc] init]; - alert.alertStyle = NSAlertStyleInformational; - alert.informativeText = SULocalizedString(@"Skipping this major upgrade will opt out of alerts for future updates.", nil); - alert.messageText = SULocalizedString(@"Are you sure you want to skip this upgrade?", nil); - - [alert addButtonWithTitle:SULocalizedString(@"Skip Upgrade", nil)]; - [alert addButtonWithTitle:SULocalizedString(@"Don't Skip", nil)]; - - [alert beginSheetModalForWindow:(NSWindow * _Nonnull)self.window completionHandler:^(NSModalResponse response) { - if (response == NSAlertFirstButtonReturn) { - [self endWithSelection:SPUUserUpdateChoiceSkip]; - } - }]; - } else { - [self endWithSelection:SPUUserUpdateChoiceSkip]; - } + [self endWithSelection:SPUUserUpdateChoiceSkip]; } - (IBAction)remindMeLater:(id)__unused sender diff --git a/Sparkle/de.lproj/Sparkle.strings b/Sparkle/de.lproj/Sparkle.strings index aebdc5f9..abf4d343 100644 --- a/Sparkle/de.lproj/Sparkle.strings +++ b/Sparkle/de.lproj/Sparkle.strings @@ -155,9 +155,6 @@ /* Skipping major upgrade */ "Skip Upgrade" = "Update überspringen"; -/* Confirmation message for skipping major upgrade and future updates */ -"Skipping this major upgrade will opt out of alerts for future updates." = "Wenn du dieses Hauptupdate überspringst, wirst du keine Hinweise für zukünftige Updates erhalten."; - /* (No Comment) */ "The update checker failed to start correctly. You should contact the app developer to report this issue and verify that you have the latest version" = "Das Aktualisierungsprogramm wurde nicht richtig gestartet. Du solltest den App-Entwickler kontaktieren, um diesen Fehler zu melden und zu prüfen, ob du die neueste Version hast."; diff --git a/Sparkle/ja.lproj/Sparkle.strings b/Sparkle/ja.lproj/Sparkle.strings index f3a631ae..81fcb406 100644 --- a/Sparkle/ja.lproj/Sparkle.strings +++ b/Sparkle/ja.lproj/Sparkle.strings @@ -91,9 +91,6 @@ /* Title confirmation for skipping major upgrade and future updates */ "Are you sure you want to skip this upgrade?" = "このアップグレードをスキップしてもよろしいですか?"; -/* Confirmation message for skipping major upgrade and future updates */ -"Skipping this major upgrade will opt out of alerts for future updates." = "このメジャーアップグレードをスキップすると、今後のアップデートも通知されなくなります。"; - /* Skipping major upgrade */ "Skip Upgrade" = "アップグレードをスキップ"; diff --git a/Sparkle/nl.lproj/Sparkle.strings b/Sparkle/nl.lproj/Sparkle.strings index dd230498..b4e2d8b7 100644 --- a/Sparkle/nl.lproj/Sparkle.strings +++ b/Sparkle/nl.lproj/Sparkle.strings @@ -155,9 +155,6 @@ /* Skipping major upgrade */ "Skip Upgrade" = "Sla update over"; -/* Confirmation message for skipping major upgrade and future updates */ -"Skipping this major upgrade will opt out of alerts for future updates." = "Als je deze hoofdupdate overslaat, zul je geen meldingen voor toekomstige updates ontvangen."; - /* (No Comment) */ "The update checker failed to start correctly. You should contact the app developer to report this issue and verify that you have the latest version" = "Het bijwerkprogramma is niet goed gestart. Je kunt wellicht met de app-ontwikkelaar contact opnemen om de fout te melden en te controleren dat je de nieuwste versie hebt"; diff --git a/Tests/Resources/testappcast_minimumAutoupdateVersionSkipping2.xml b/Tests/Resources/testappcast_minimumAutoupdateVersionSkipping2.xml new file mode 100644 index 00000000..36816a21 --- /dev/null +++ b/Tests/Resources/testappcast_minimumAutoupdateVersionSkipping2.xml @@ -0,0 +1,38 @@ + + + + For unit test only + + Version 4.1 + 4.1 + 4.0 + + + + Version 4.0 + 4.0 + 4.0 + + + + Version 3.9 + 3.9 + 3.0 + 3.5 + + + + Version 3.0 + 3.0 + 3.0 + + + + Version 2.0 + + 2.0 + 2.0 + + + + diff --git a/Tests/SUAppcastTest.swift b/Tests/SUAppcastTest.swift index fb29c164..a1e921db 100644 --- a/Tests/SUAppcastTest.swift +++ b/Tests/SUAppcastTest.swift @@ -358,7 +358,7 @@ class SUAppcastTest: XCTestCase { // There should be no items if 2.0 is skipped from 1.0 and 3.0 fails minimum autoupdate version do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: nil) + let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: nil, majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true) @@ -367,7 +367,7 @@ class SUAppcastTest: XCTestCase { // Try again but allowing minimum autoupdate version to fail do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: nil) + let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: nil, majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -380,7 +380,7 @@ class SUAppcastTest: XCTestCase { // Allow minimum autoupdate version to fail and only skip 3.0 do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -393,7 +393,7 @@ class SUAppcastTest: XCTestCase { // Allow minimum autoupdate version to fail skipping both 2.0 and 3.0 do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: "3.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.0", majorVersion: "3.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -403,7 +403,7 @@ class SUAppcastTest: XCTestCase { // Allow minimum autoupdate version to fail and only skip "2.5" // This should implicitly only skip 2.0 do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.5", majorVersion: nil) + let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.5", majorVersion: nil, majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -416,7 +416,7 @@ class SUAppcastTest: XCTestCase { // This should not skip anything but require passing minimum autoupdate version do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: nil) + let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: nil, majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true) @@ -429,7 +429,7 @@ class SUAppcastTest: XCTestCase { // This should not skip anything but allow failing minimum autoupdate version do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: nil) + let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: nil, majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -442,7 +442,7 @@ class SUAppcastTest: XCTestCase { // This should not skip anything but require passing minimum autoupdate version do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: "1.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: "1.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true) @@ -455,7 +455,7 @@ class SUAppcastTest: XCTestCase { // This should not skip anything but allow failing minimum autoupdate version do { - let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: "1.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: "1.5", majorVersion: "1.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -516,7 +516,7 @@ class SUAppcastTest: XCTestCase { let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator) let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver) - let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -535,7 +535,7 @@ class SUAppcastTest: XCTestCase { let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator) let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver) - let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: true) @@ -554,7 +554,7 @@ class SUAppcastTest: XCTestCase { let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator) let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver) - let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "4.0") + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "4.0", majorSubreleaseVersion: nil) let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) @@ -570,6 +570,128 @@ class SUAppcastTest: XCTestCase { } } + func testMinimumAutoupdateVersionIgnoringSkipping() { + let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast_minimumAutoupdateVersionSkipping2", withExtension: "xml")! + + do { + let testData = try Data(contentsOf: testURL) + + let versionComparator = SUStandardVersionComparator() + + let currentDate = Date() + + do { + let hostVersion = "1.0" + + let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator) + let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver) + + // Allow minimum autoupdate version to fail and only skip major version "3.0" with no subrelease version + // This should skip all 3.x versions except for 3.9 which ignores skipped upgrades below 3.5, but not 4.x versions nor 2.x versions + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: nil) + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(4, supportedAppcast.items.count) + + XCTAssertEqual(supportedAppcast.items[0].versionString, "4.1") + XCTAssertEqual(supportedAppcast.items[1].versionString, "4.0") + XCTAssertEqual(supportedAppcast.items[2].versionString, "3.9") + XCTAssertEqual(supportedAppcast.items[3].versionString, "2.0") + + let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator) + + XCTAssertEqual(bestAppcastItem.versionString, "4.1") + } + + // Allow minimum autoupdate version to fail and only skip major version "3.0" with subrelease version 3.4 + // This should skip all 3.x versions except for 3.9 which ignores skipped upgrades below 3.5, but not 4.x versions nor 2.x versions + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.4", majorSubreleaseVersion: nil) + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(4, supportedAppcast.items.count) + + XCTAssertEqual(supportedAppcast.items[0].versionString, "4.1") + XCTAssertEqual(supportedAppcast.items[1].versionString, "4.0") + XCTAssertEqual(supportedAppcast.items[2].versionString, "3.9") + XCTAssertEqual(supportedAppcast.items[3].versionString, "2.0") + + let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator) + + XCTAssertEqual(bestAppcastItem.versionString, "4.1") + } + + // Allow minimum autoupdate version to fail and only skip major version "3.0" with subrelease version 3.5 + // This should skip all 3.x versions, but not 4.x versions nor 2.x versions + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: "3.5") + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(3, supportedAppcast.items.count) + + XCTAssertEqual(supportedAppcast.items[0].versionString, "4.1") + XCTAssertEqual(supportedAppcast.items[1].versionString, "4.0") + XCTAssertEqual(supportedAppcast.items[2].versionString, "2.0") + + let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator) + + XCTAssertEqual(bestAppcastItem.versionString, "4.1") + } + + // Allow minimum autoupdate version to fail and only skip major version "3.0" with subrelease version 3.5.1 + // This should skip all 3.x versions, but not 4.x versions nor 2.x versions + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "3.0", majorSubreleaseVersion: "3.5.1") + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(3, supportedAppcast.items.count) + + XCTAssertEqual(supportedAppcast.items[0].versionString, "4.1") + XCTAssertEqual(supportedAppcast.items[1].versionString, "4.0") + XCTAssertEqual(supportedAppcast.items[2].versionString, "2.0") + + let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator) + + XCTAssertEqual(bestAppcastItem.versionString, "4.1") + } + + // Allow minimum autoupdate version to fail and only skip major version "4.0" with subrelease version 4.0 + // This should skip all 3.x versions and 4.x versions, but not 2.x versions + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: nil, majorVersion: "4.0", majorSubreleaseVersion: "4.0") + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(1, supportedAppcast.items.count) + + XCTAssertEqual(supportedAppcast.items[0].versionString, "2.0") + + let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcast.items, getDeltaItem: nil, withHostVersion: hostVersion, comparator: versionComparator) + + XCTAssertEqual(bestAppcastItem.versionString, "2.0") + } + + // Allow minimum autoupdate version to fail and only skip major version "4.0" with subrelease version 4.0, and skip minor version 2.1 + // This should skip everything + do { + let skippedUpdate = SPUSkippedUpdate(minorVersion: "2.1", majorVersion: "4.0", majorSubreleaseVersion: "4.0") + + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: skippedUpdate, currentDate: currentDate, hostVersion: hostVersion, versionComparator: versionComparator, testOSVersion: true, testMinimumAutoupdateVersion: false) + + XCTAssertEqual(0, supportedAppcast.items.count) + } + } + } catch let err as NSError { + NSLog("%@", err) + XCTFail(err.localizedDescription) + } + } + func testPhasedGroupRollouts() { let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast_phasedRollout", withExtension: "xml")!