Skip to content

Commit 11b5ddb

Browse files
authored
Make scripts/style.sh compatible with newer swiftformat versions (0.38) (#2334)
* Log swiftformat version in non-interactive builds. * Use a mildly-terrible regex for version check to ensure at least 0.35.0 (travis has 0.35.8). * Include StorageViewController.swift change swiftformat 0.38 makes (but which seems to be compatible with 0.35)
1 parent 61f173e commit 11b5ddb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Example/tvOSSample/tvOSSample/StorageViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StorageViewController: UIViewController {
4242
}
4343
}
4444

45-
/// MARK: - Properties
45+
// MARK: - Properties
4646

4747
/// The current internal state of the view controller.
4848
private var state: UIState = .cleared {

scripts/style.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,17 @@ esac
5858
system=$(uname -s)
5959
if [[ "$system" == "Darwin" ]]; then
6060
version=$(swiftformat --version)
61+
# Log the version in non-interactive use as it can be useful in travis logs.
62+
if [[ ! -t 1 ]]; then
63+
echo "Found: $version"
64+
fi
6165
version="${version/*version /}"
62-
# Allow an older swiftformat because travis isn't running High Sierra yet
63-
# and the formula hasn't been updated in a while on Sierra :-/.
64-
if [[ "$version" != "0.32.0" && "$version" != "0.33"* && "$version" != "0.35"* && "$version" != "0.37"* ]]; then
65-
echo "Version $version installed. Please upgrade to at least swiftformat 0.33.8"
66+
# Ensure the swiftformat version is at least 0.35.x since (as of 2019-02-01)
67+
# travis runs 0.35.7. We may need to be more strict about version checks in
68+
# the future if we run into different versions making incompatible format
69+
# changes.
70+
if [[ ! "$version" =~ ^0.3[5-9] && ! "$version" =~ ^0.[4-9] ]]; then
71+
echo "Version $version installed. Please upgrade to at least swiftformat 0.35.0"
6672
echo "If it's installed via homebrew you can run: brew upgrade swiftformat"
6773
exit 1
6874
fi

0 commit comments

Comments
 (0)