Skip to content

Commit

Permalink
Fixes sparkle-project#222: Long version ids (12 digits based on rever…
Browse files Browse the repository at this point in the history
…se date) cause update to work no longer
  • Loading branch information
andymatuschak committed Nov 16, 2012
1 parent b86770c commit 7b3928d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions SUStandardVersionComparator.m
Expand Up @@ -84,8 +84,8 @@ - (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)
NSArray *partsB = [self splitVersionString:versionB];

NSString *partA, *partB;
NSUInteger i, n;
int intA, intB;
int i, n;
long long valueA, valueB;
SUCharacterType typeA, typeB;

n = MIN([partsA count], [partsB count]);
Expand All @@ -100,11 +100,11 @@ - (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)
if (typeA == typeB) {
// Same type; we can compare
if (typeA == kNumberType) {
intA = [partA intValue];
intB = [partB intValue];
if (intA > intB) {
valueA = [partA longLongValue];
valueB = [partB longLongValue];
if (valueA > valueB) {
return NSOrderedDescending;
} else if (intA < intB) {
} else if (valueA < valueB) {
return NSOrderedAscending;
}
} else if (typeA == kStringType) {
Expand Down
5 changes: 5 additions & 0 deletions Tests/SUVersionComparisonTest.m
Expand Up @@ -59,4 +59,9 @@ - (void)testWordsWithSpaceInFront
// SUAssertEqual(@"1.0 - beta", @"1.0 beta");
}

- (void)testVersionsWithReverseDateBasedNumbers
{
SUAssertAscending(@"201210251627", @"201211051041");
}

@end

0 comments on commit 7b3928d

Please sign in to comment.