summaryrefslogtreecommitdiffstats
path: root/solenv/clang-format/reformat-formatted-files
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /solenv/clang-format/reformat-formatted-files
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'solenv/clang-format/reformat-formatted-files')
-rwxr-xr-xsolenv/clang-format/reformat-formatted-files49
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..04b0adde8
--- /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 blacklisted. 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 $blacklist_names = ClangFormat::get_blacklist();
+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($blacklist_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);
+ }
+}
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: