diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-13 09:08:30 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-13 10:43:39 +0100 |
commit | 53e13b256fa5082eb29ea2addd1bfa184827e53b (patch) | |
tree | 820c9e5ec61ce4cb1c6713a71aedfd8a0383fa01 /solenv | |
parent | 70fa61918415f642228127847491224078532218 (diff) |
clang-format: standardize on 5.0.0
Restrict the git hook further to only enforce style in case the found
clang-format binary's version matches to avoid output differences with
different clang-format version.
While at it, move the blacklist reading after the version check to speed
up committing a bit when no local enforcement happens.
Also add a simple script to list formatted files, since the blacklist is
large enough that doing it naively from the shell is too slow.
Change-Id: I0bc05961d262cc6bc91c6efdd1b91994ecfc6940
Reviewed-on: https://gerrit.libreoffice.org/44662
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/clang-format/list-formatted-files | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/solenv/clang-format/list-formatted-files b/solenv/clang-format/list-formatted-files new file mode 100755 index 000000000000..4dfd4bfc0c34 --- /dev/null +++ b/solenv/clang-format/list-formatted-files @@ -0,0 +1,40 @@ +#!/usr/bin/env perl + +# Lists source files which are not blacklisted. This is interesting if the +# clang-format version or config changes. To trigger a reformat in that case, +# you can do: +# +# clang-format -i $(solenv/clang-format/list-formatted-files) + +sub check_style() +{ + my $src = "c|cpp|cxx|h|hxx|inl"; + my %blacklist_names = (); + + # Read the blacklist. + if (open(LINES, "solenv/clang-format/blacklist")) + { + while (my $line = <LINES>) + { + chomp $line; + $blacklist_names{$line} = 1; + } + } + + # Get a list of files. + open (FILES, "git ls-files |") || die "Cannot run git ls-files."; + while (my $filename = <FILES>) + { + chomp $filename; + if ($filename =~ /\.($src)$/ and !exists($blacklist_names{$filename})) + { + print($filename . "\n"); + } + } +} + +check_style(); + +exit(0); + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |