diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-11-13 11:59:08 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-11-13 11:59:08 +0100 |
commit | e61a1b8dd8d4ea99f50eed3f8118bc01a0617889 (patch) | |
tree | 1c736091608738957d8616226418da169d109a76 /.git-hooks | |
parent | 0c5eda9876f353e0516171fec67568643f24c5b6 (diff) |
First look for clang-format in CLANG_FORMT env var
Change-Id: I5de5c6f3e8be1d40c03cbddb9d2f4414b9a5791b
Diffstat (limited to '.git-hooks')
-rwxr-xr-x | .git-hooks/pre-commit | 20 |
1 files changed, 12 insertions, 8 deletions
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; + } } } } |