-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add update checker #5613
base: main
Are you sure you want to change the base?
Add update checker #5613
Conversation
var request = URLRequest(url: url) | ||
request.setValue("SwiftLint", forHTTPHeaderField: "User-Agent") | ||
request.setValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept") | ||
let semaphore = DispatchSemaphore(value: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we go with some Swift Concurrency magic here instead? I assume the whole method chain can be async
.
let minor = components.dropFirst(1).first ?? 0 | ||
let patch = components.dropFirst(2).first ?? 0 | ||
return [major, minor, patch] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a similar (or equal) implementation for SwiftVersion
. Can we somehow reduce them to just one? Something like VersionComparable
with a default implementation that only relies on the underlying version string.
5017b0f
to
735f371
Compare
Here's an example of your CHANGELOG entry: * Add update checker.
[mildm8nnered](https://github.com/mildm8nnered)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
16ea749
to
e7bc567
Compare
6899365
to
a86b335
Compare
Adds an update check facility to SwiftLint - addresses #5551
This has been added as a
--check-for-updates
command line option to theversion
,lint
, andanalyze
commands.It can also be enabled via the configuration file, as
check_for_updates
.Although the usefulness of an opt-in option is limited, at least this provides a good story for how users can keep their installs up to date. And it could easily be changed to opt-out either here or at some later date.
The update checker code is pretty closely based on Periphery's implementation, and should probably be credited in the source file.
The update check is performed after all other processing, so linting will never be delayed, and the code is completely synchronous, as we do not have to worry about blocking the main thread.
The messaging for a new version is:
A new version of SwiftLint is available: 0.51.1
We currently do not print any messaging if the update check fails, which is probably wrong.