From e61a1b8dd8d4ea99f50eed3f8118bc01a0617889 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 13 Nov 2017 11:59:08 +0100 Subject: First look for clang-format in CLANG_FORMT env var Change-Id: I5de5c6f3e8be1d40c03cbddb9d2f4414b9a5791b --- .git-hooks/pre-commit | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to '.git-hooks') diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 3743f6b79d6c..5c7c14b8d4a7 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -127,19 +127,23 @@ sub check_style($) my @bad_names = (); my %blacklist_names = (); - # Use clang-format from PATH, unless it's available in our dedicated + # Use clang-format from CLANG_FORMAT, or from PATH unless it's available in our dedicated # directory. - my $opt_lo = "/opt/lo/bin"; - my $clang_format = "$opt_lo/clang-format"; my $version = "5.0.0"; - if (!is_matching_clang_format_version($clang_format, $version)) + my $opt_lo = "/opt/lo/bin"; + my $clang_format = $ENV{CLANG_FORMAT}; + if (!(defined($clang_format) && is_matching_clang_format_version($clang_format, $version))) { - foreach my $dir (split /:/, $ENV{PATH}) + $clang_format = "$opt_lo/clang-format"; + if (!is_matching_clang_format_version($clang_format, $version)) { - $clang_format = "$dir/clang-format"; - if (is_matching_clang_format_version($clang_format, $version)) + foreach my $dir (split /:/, $ENV{PATH}) { - last; + $clang_format = "$dir/clang-format"; + if (is_matching_clang_format_version($clang_format, $version)) + { + last; + } } } } -- cgit