Skip to content

Commit 9a297e0

Browse files
authored
Merge pull request #1396 from ychin/sparkle-more-descriptive-version-string
Use more descriptive version string in Sparkle 2
2 parents 4b30143 + c311abc commit 9a297e0

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/MacVim/MMSparkle2Delegate.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@
88

99
#import "Sparkle.framework/Headers/Sparkle.h"
1010

11-
@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate, SUVersionDisplay>;
1214

1315
// SPUUpdaterDelegate
14-
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater;
16+
- (NSSet<NSString *> *)allowedChannelsForUpdater:(SPUUpdater *)updater;
1517

1618
// SPUStandardUserDriverDelegate
17-
// No need to implement anything for now. Default behaviors work fine.
19+
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;
20+
21+
// SUVersionDisplay
22+
- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion;
23+
24+
- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate;
1825

1926
@end
2027

28+
NS_ASSUME_NONNULL_END
29+
2130
#endif

src/MacVim/MMSparkle2Delegate.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ @implementation MMSparkle2Delegate;
2424
return [NSSet<NSString *> set];
2525
}
2626

27+
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer
28+
{
29+
return self;
30+
}
31+
32+
/// MacVim has a non-standard way of using "bundle version" and "display version",
33+
/// where the display version is the upstream Vim version, and the bundle version
34+
/// is the release number of MacVim itself. The release number is more useful to
35+
/// know when updating MacVim, but both should be displayed. Format them nicely so
36+
/// it's clear to the user which is which. By default Sparkle would only show display
37+
/// version which is problematic as that wouldn't show the release number which we
38+
/// care about.
39+
NSString* formatVersionString(NSString* bundleVersion, NSString* displayVersion)
40+
{
41+
return [NSString stringWithFormat:@"r%@ (Vim %@)", bundleVersion, displayVersion];
42+
}
43+
44+
- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion
45+
{
46+
*inOutBundleDisplayVersion = formatVersionString(bundleVersion, *inOutBundleDisplayVersion);
47+
return formatVersionString(update.versionString, update.displayVersionString);
48+
}
49+
50+
- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate
51+
{
52+
return formatVersionString(bundleVersion, bundleDisplayVersion);
53+
}
54+
55+
2756
@end;
2857

2958
#endif

0 commit comments

Comments
 (0)