mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Add sparkle:belowVersion element for informational updates (#2080)
This allows marking all updates below a specific version as informational only. A new element (sparkle:belowVersion) was introduced this over a new attribute for sparkle:version due to compatibility reasons.
This commit is contained in:
6 files changed
+65
-2
No files matched your search
+15
-1
@@ -98,8 +98,22 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSString *hostVersion = self.hostVersion;
|
||||
|
||||
// Informational update only for a set of host versions we're updating from
|
||||
return [informationalUpdateVersions containsObject:self.hostVersion];
|
||||
if ([informationalUpdateVersions containsObject:hostVersion]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// If an informational update version has a '<' prefix, this is an informational update if
|
||||
// hostVersion < this info update version
|
||||
for (NSString *informationalUpdateVersion in informationalUpdateVersions) {
|
||||
if ([informationalUpdateVersion hasPrefix:@"<"] && [self.applicationVersionComparator compareVersion:hostVersion toVersion:[informationalUpdateVersion substringFromIndex:1]] == NSOrderedAscending) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (SPUAppcastItemState *)resolveStateWithInformationalUpdateVersions:(NSSet<NSString *> * _Nullable)informationalUpdateVersions minimumOperatingSystemVersion:(NSString * _Nullable)minimumOperatingSystemVersion maximumOperatingSystemVersion:(NSString * _Nullable)maximumOperatingSystemVersion minimumAutoupdateVersion:(NSString * _Nullable)minimumAutoupdateVersion criticalUpdateDictionary:(NSDictionary * _Nullable)criticalUpdateDictionary
|
||||
|
||||
Vendored
+7
-1
@@ -159,11 +159,17 @@
|
||||
NSMutableSet *informationalUpdateVersions = [NSMutableSet set];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([child.name isEqualToString:SUAppcastAttributeVersion]) {
|
||||
if ([child.name isEqualToString:SUAppcastElementVersion]) {
|
||||
NSString *version = child.stringValue;
|
||||
if (version != nil) {
|
||||
[informationalUpdateVersions addObject:version];
|
||||
}
|
||||
} else if ([child.name isEqualToString:SUAppcastElementBelowVersion]) {
|
||||
NSString *version = child.stringValue;
|
||||
if (version != nil) {
|
||||
// Denote version is used as an upper bound by using '<'
|
||||
[informationalUpdateVersions addObject:[NSString stringWithFormat:@"<%@", version]];
|
||||
}
|
||||
}
|
||||
}
|
||||
[dict setObject:[informationalUpdateVersions copy] forKey:name];
|
||||
|
||||
Vendored
+1
@@ -94,6 +94,7 @@ extern NSString *const SUAppcastElementTags;
|
||||
extern NSString *const SUAppcastElementPhasedRolloutInterval;
|
||||
extern NSString *const SUAppcastElementInformationalUpdate;
|
||||
extern NSString *const SUAppcastElementChannel;
|
||||
extern NSString *const SUAppcastElementBelowVersion;
|
||||
|
||||
extern NSString *const SURSSAttributeURL;
|
||||
extern NSString *const SURSSAttributeLength;
|
||||
|
||||
Vendored
+1
@@ -91,6 +91,7 @@ NSString *const SUAppcastElementTags = @"sparkle:tags";
|
||||
NSString *const SUAppcastElementPhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
|
||||
NSString *const SUAppcastElementInformationalUpdate = @"sparkle:informationalUpdate";
|
||||
NSString *const SUAppcastElementChannel = @"sparkle:channel";
|
||||
NSString *const SUAppcastElementBelowVersion = @"sparkle:belowVersion";
|
||||
|
||||
NSString *const SURSSAttributeURL = @"url";
|
||||
NSString *const SURSSAttributeLength = @"length";
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<sparkle:informationalUpdate>
|
||||
<sparkle:version>2.5</sparkle:version>
|
||||
<sparkle:version>2.4</sparkle:version>
|
||||
<sparkle:belowVersion>0.5</sparkle:belowVersion>
|
||||
</sparkle:informationalUpdate>
|
||||
<link>http://sparkle-project.org</link>
|
||||
</item>
|
||||
|
||||
@@ -205,6 +205,16 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// Test informational updates from version 2.3
|
||||
do {
|
||||
let hostVersion = "2.3"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
XCTAssertFalse(appcast.items[1].isInformationOnlyUpdate)
|
||||
}
|
||||
|
||||
// Test informational updates from version 2.4
|
||||
do {
|
||||
let hostVersion = "2.4"
|
||||
@@ -235,6 +245,36 @@ class SUAppcastTest: XCTestCase {
|
||||
XCTAssertFalse(appcast.items[1].isInformationOnlyUpdate)
|
||||
}
|
||||
|
||||
// Test informational updates from version 0.5
|
||||
do {
|
||||
let hostVersion = "0.5"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
XCTAssertFalse(appcast.items[1].isInformationOnlyUpdate)
|
||||
}
|
||||
|
||||
// Test informational updates from version 0.4
|
||||
do {
|
||||
let hostVersion = "0.4"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
XCTAssertTrue(appcast.items[1].isInformationOnlyUpdate)
|
||||
}
|
||||
|
||||
// Test informational updates from version 0.0
|
||||
do {
|
||||
let hostVersion = "0.0"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
|
||||
XCTAssertTrue(appcast.items[1].isInformationOnlyUpdate)
|
||||
}
|
||||
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
|
||||
Reference in new issue
Block a user