Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / solenv / clang-format / reformat-formatted-files
blob04b0adde8e4e96f841f97830773fd3e5ffbf3e77
1 #!/usr/bin/env perl
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # Reformat files which are not blacklisted. This is interesting if the
9 # clang-format version or config changes.
10 # -n allows just listing the formatted files.
12 use strict;
13 use warnings;
14 use lib "solenv/clang-format";
15 use ClangFormat;
17 my $clang_format = ClangFormat::find();
18 my $src = ClangFormat::get_extension_regex();
19 my $blacklist_names = ClangFormat::get_blacklist();
20 my @filenames = ();
21 my $dry_run = 0;
23 # Get a list of files.
24 open (FILES, "git ls-files |") || die "Cannot run git ls-files.";
25 while (my $filename = <FILES>)
27 chomp $filename;
28 if ($filename =~ /\.($src)$/ and !exists($blacklist_names->{$filename}))
30 push @filenames, $filename;
34 if ($#ARGV ge 0 && $ARGV[0] eq "-n")
36 $dry_run = 1;
39 foreach my $filename (@filenames)
41 my $command = $clang_format . " -i " . $filename;
42 print($filename . "\n");
43 if (!$dry_run)
45 system($command);
49 # vim: set shiftwidth=4 softtabstop=4 expandtab: