Skip to content

Add more flexible swiftformat version check to scripts/style.sh. #2334

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 3 commits into from
Feb 1, 2019
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
2 changes: 1 addition & 1 deletion Example/tvOSSample/tvOSSample/StorageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class StorageViewController: UIViewController {
}
}

/// MARK: - Properties
// MARK: - Properties

/// The current internal state of the view controller.
private var state: UIState = .cleared {
Expand Down
14 changes: 10 additions & 4 deletions scripts/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ esac
system=$(uname -s)
if [[ "$system" == "Darwin" ]]; then
version=$(swiftformat --version)
# Log the version in non-interactive use as it can be useful in travis logs.
if [[ ! -t 1 ]]; then
echo "Found: $version"
fi
version="${version/*version /}"
# Allow an older swiftformat because travis isn't running High Sierra yet
# and the formula hasn't been updated in a while on Sierra :-/.
if [[ "$version" != "0.32.0" && "$version" != "0.33"* && "$version" != "0.35"* && "$version" != "0.37"* ]]; then
echo "Version $version installed. Please upgrade to at least swiftformat 0.33.8"
# Ensure the swiftformat version is at least 0.35.x since (as of 2019-02-01)
# travis runs 0.35.7. We may need to be more strict about version checks in
# the future if we run into different versions making incompatible format
# changes.
if [[ ! "$version" =~ ^0.3[5-9] && ! "$version" =~ ^0.[4-9] ]]; then
echo "Version $version installed. Please upgrade to at least swiftformat 0.35.0"
echo "If it's installed via homebrew you can run: brew upgrade swiftformat"
exit 1
fi
Expand Down