diff options
author | Rich Gowman <rgowman@google.com> | 2018-06-12 10:50:07 -0400 |
---|---|---|
committer | Rich Gowman <rgowman@google.com> | 2018-06-12 10:50:07 -0400 |
commit | 86cdae83a0b7b36d8a7c61eb3704b28f9f31a041 (patch) | |
tree | bb1dc7167d8eddb9e872780da357026f7ce1d83c /scripts/style.sh | |
parent | cf2899a085f7ceca3fad2d1fb5336be25cecd7ff (diff) | |
parent | f5bf0a37a7dd40e7538a1aed77af05471b7fe713 (diff) |
Merge remote-tracking branch 'origin/master' into rsgowman/protobuf_cpp
Diffstat (limited to 'scripts/style.sh')
-rwxr-xr-x | scripts/style.sh | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/scripts/style.sh b/scripts/style.sh index 8eff1e8..f82af77 100755 --- a/scripts/style.sh +++ b/scripts/style.sh @@ -21,18 +21,36 @@ # Commonly # ./scripts/style.sh master -system=$(uname -s) - +# Strip the clang-format version output down to the major version. Examples: +# clang-format version 7.0.0 (tags/google/stable/2018-01-11) +# clang-format version google3-trunk (trunk r333779) version=$(clang-format --version) + +# Remove leading "clang-format version" version="${version/*version /}" +# Remove trailing parenthetical version details +version="${version/ (*)/}" +# Remove everything after the first dot (note this is a glob, not a regex) version="${version/.*/}" -if [[ "$version" != 6 && "$version" != 7 ]]; then - # Allow an older clang-format to accommodate Travis version skew. - echo "Please upgrade to clang-format version 7." - echo "If it's installed via homebrew you can run: brew upgrade clang-format" - exit 1 -fi +case "$version" in + 6 | 7) + # Allow an older clang-format to accommodate Travis version skew. + ;; + google3-trunk) + echo "Please use a publicly released clang-format; a recent LLVM release" + echo "from http://releases.llvm.org/download.html will work." + echo "Prepend to PATH when running style.sh." + exit 1 + ;; + *) + echo "Please upgrade to clang-format version 7." + echo "If it's installed via homebrew you can run: brew upgrade clang-format" + exit 1 + ;; +esac + +system=$(uname -s) if [[ "$system" == "Darwin" ]]; then version=$(swiftformat --version) version="${version/*version /}" |