From 4149cdeb0128facacfb2d09ddcfa0661259c177f Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Fri, 10 Jun 2022 16:24:30 +0200 Subject: Fix ktlint hook In ag/18798895, I broke the early exit condition when the ktlint hook would receive 0 Kotlin files. Since that CL, ktlint would always run on a big number of files if th CL didn't contain any change in a .kt or .kts file. Bug: 235461679 Test: Manual Change-Id: Iaf21df8e85943229c1d832b186825b41cf231b2d --- ktlint.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ktlint.py b/ktlint.py index 80703a4..86b15ed 100755 --- a/ktlint.py +++ b/ktlint.py @@ -45,12 +45,13 @@ def main(args=None): parser.set_defaults(format=False) args = parser.parse_args() kt_files = [f for f in args.file if f.endswith('.kt') or f.endswith('.kts')] + if not kt_files: + sys.exit(0) + ktlint_args = kt_files[:] ktlint_args += ['--editorconfig', EDITOR_CONFIG] if args.format: ktlint_args += ['-F'] - if not ktlint_args: - sys.exit(0) ktlint_args += ['--android'] -- cgit v1.2.3