Skip to content

Use more descriptive version string in Sparkle 2 #1396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
15 changes: 12 additions & 3 deletions src/MacVim/MMSparkle2Delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@

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

@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;
NS_ASSUME_NONNULL_BEGIN

@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate, SUVersionDisplay>;

// SPUUpdaterDelegate
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater;
- (NSSet<NSString *> *)allowedChannelsForUpdater:(SPUUpdater *)updater;

// SPUStandardUserDriverDelegate
// No need to implement anything for now. Default behaviors work fine.
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;

// SUVersionDisplay
- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion;

- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate;

@end

NS_ASSUME_NONNULL_END

#endif
29 changes: 29 additions & 0 deletions src/MacVim/MMSparkle2Delegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,35 @@ @implementation MMSparkle2Delegate;
return [NSSet<NSString *> set];
}

- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer
{
return self;
}

/// MacVim has a non-standard way of using "bundle version" and "display version",
/// where the display version is the upstream Vim version, and the bundle version
/// is the release number of MacVim itself. The release number is more useful to
/// know when updating MacVim, but both should be displayed. Format them nicely so
/// it's clear to the user which is which. By default Sparkle would only show display
/// version which is problematic as that wouldn't show the release number which we
/// care about.
NSString* formatVersionString(NSString* bundleVersion, NSString* displayVersion)
{
return [NSString stringWithFormat:@"r%@ (Vim %@)", bundleVersion, displayVersion];
}

- (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion
{
*inOutBundleDisplayVersion = formatVersionString(bundleVersion, *inOutBundleDisplayVersion);
return formatVersionString(update.versionString, update.displayVersionString);
}

- (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate
{
return formatVersionString(bundleVersion, bundleDisplayVersion);
}


@end;

#endif