#!/usr/bin/env python3 # 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/. import os from difflib import unified_diff from pathlib import Path from subprocess import PIPE, Popen EXCLUDELIST = Path("solenv/clang-format/excludelist") THRESHOLD = os.getenv("CLANG_THRESHOLD", 5) CLANG_BINARY = Path(os.getenv("CLANG_FORMAT", "/opt/lo/bin/clang-format")) def calculate_diff_size(diff): additions, removals = 0, 0 # ignore first 2 item in the sequence # which are +++ and --- for line in diff[2:]: if line.startswith("+"): additions += 1 elif line.startswith("-"): removals += 1 return max((additions, removals)) def format_stream(path, *extra_args): process = Popen( [CLANG_BINARY, *extra_args], stdout=PIPE, stderr=PIPE, stdin=PIPE, ) stdout, stderr = process.communicate(input=path.read_bytes()) if stderr: print("", str(path)) print(stderr.decode()) print("") exit(1) stdout = stdout.decode() return stdout def main(*args): if not CLANG_BINARY.exists(): print("Couldn't find clang-format on {!s}".format(CLANG_BINARY)) exit(1) for path in EXCLUDELIST.read_text().splitlines(): path = Path(path) if not path.exists(): continue original = path.read_text() new = format_stream(path, *args) originalsize = len(original.splitlines()) diff = unified_diff(original.splitlines(), new.splitlines(), n=0) diffsize = calculate_diff_size(tuple(diff)) if diffsize <= (originalsize * 5) // 100: print(path, "(size: {}/{})".format(diffsize, originalsize)) if __name__ == "__main__": import sys main(*sys.argv[1:]) stro/cib/libreoffice-6-4'>distro/cib/libreoffice-6-4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2023-03-19MCGR: Model data changes for ColorStepsArmin Le Grand (allotropia)
2023-03-04MCGR: ColorSteps handling moved to toolingArmin Le Grand (allotropia)
2023-02-07improve readability of VirtualDevice constructorNoel Grandin
2022-11-06Remove double functionalityArmin Le Grand (allotropia)
2022-01-14Recheck modules d* with IWYUGabor Kelemen
2021-12-16Remove transitional header drawinglayer/primitive2d/polygonprimitive2d.hxxGabor Kelemen
2021-10-16Simplify vector initialization in drawinglayerJulien Nabet
2021-10-06loplugin:moveparam in drawinglayerNoel Grandin
2021-09-03Remove some unused includesMiklos Vajna
2021-05-21properly draw only parts of FillGradientPrimitive2D (tdf#139000)Luboš Luňák
2021-05-18loplugin:unusedfieldsNoel Grandin
2021-05-06add a unittest for impress drawing a dotted line in tdf#136957Luboš Luňák
2021-02-18loplugin:referencecasting add check for new rtl::Reference operatorNoel
2020-05-18comphelper, drawinglayer, framework, starmath: clang-format these filesMiklos Vajna
2019-07-03Remove some unused includesMiklos Vajna
2019-02-14CppunitTest_drawinglayer_border: use CPPUNIT_TEST_FIXTURE()Miklos Vajna
2018-10-25Reorganize FrameBorderPrimitive creation (II)Armin Le Grand
2017-12-22tdf#42949 Fix some Include What You Use warningsMiklos Vajna
2017-12-06Remove unused #include <vcl/metaact.hxx> from vcl/outdev.hxxStephan Bergmann
2017-09-15borderline: Adapted BorderLinePrimitive2D and usagesArmin Le Grand
2017-09-15borderline: Abstraction of BorderLinePrimitiveArmin Le Grand
2017-07-28borderline: corrections for calc and writerArmin Le Grand
2017-07-12borderline: correct problems with border displayArmin Le Grand
2017-06-23loplugin:oncevar in cppcanvas..drawinglayerNoel Grandin
2017-04-25tools: svstream.hxx needs only errcode.hxx & not errinf.hxxChris Sherlock
2017-03-17convert SvxBorderStyle to scoped enumNoel Grandin
2016-11-08reduce copying when decomposing drawinglayer primitivesNoel Grandin
2016-04-19drawinglayer, sw: indentation fixesMiklos Vajna
2016-04-18tdf#99315 VclPixelProcessor2D: fix double border line widthMiklos Vajna
2016-04-15loplugin:refcountingStephan Bergmann
2016-04-15Related: tdf#99315 BorderLinePrimitive2D: fix solid line primitive widthMiklos Vajna