Files
odfstudio/solenv/clang-format/reformat-formatted-files
T
Pierre 2ab69c32cf tdf#169010 obsolete generate-style-excludelist and cleanup excludelist
perlify .git-hooks/pre-commit; for readability, should clarify git calls
perlify reformat-formatted-files;

Change-Id: I947848738e0f80b992ed1852caa3f81ea201bbc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192913
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2026-02-04 14:36:58 +01:00

38 lines
1.1 KiB
Perl
Executable File

#!/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() . ' -i ';
my $re_ext = '\.('. ClangFormat::get_extension_regex() .')$';
my $excluded_list_names = ClangFormat::get_excludelist();
my $dry_run = $ARGV[0] eq '-n';
# Get a list of files.
open (FILES, 'git ls-files |') or die 'Cannot run git ls-files.';
my @filenames = grep { chomp $_; /$re_ext/ and !exists($excluded_list_names->{$_}) } <FILES>;
foreach my $filename (@filenames)
{
print($filename, "\n");
if (!$dry_run)
{
system($clang_format . $filename) == 0 or die qq(failed to execute "$clang_format $filename": $?);
}
}
# vim: set shiftwidth=4 softtabstop=4 expandtab: