diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /solenv/clang-format/reformat-formatted-files | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'solenv/clang-format/reformat-formatted-files')
-rwxr-xr-x | solenv/clang-format/reformat-formatted-files | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/solenv/clang-format/reformat-formatted-files b/solenv/clang-format/reformat-formatted-files new file mode 100755 index 000000000..a3a670f83 --- /dev/null +++ b/solenv/clang-format/reformat-formatted-files @@ -0,0 +1,49 @@ +#!/usr/bin/env perl +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Reformat files which are not excluded. This is interesting if the +# clang-format version or config changes. +# -n allows just listing the formatted files. + +use strict; +use warnings; +use lib "solenv/clang-format"; +use ClangFormat; + +my $clang_format = ClangFormat::find(); +my $src = ClangFormat::get_extension_regex(); +my $excluded_list_names = ClangFormat::get_excludelist(); +my @filenames = (); +my $dry_run = 0; + +# 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($excluded_list_names->{$filename})) + { + push @filenames, $filename; + } +} + +if ($#ARGV ge 0 && $ARGV[0] eq "-n") +{ + $dry_run = 1; +} + +foreach my $filename (@filenames) +{ + my $command = $clang_format . " -i " . $filename; + print($filename . "\n"); + if (!$dry_run) + { + system($command) == 0 or die "failed to execute \"$command\": $?"; + } +} + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |