summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Demeulenaere <jdemeulenaere@google.com>2022-06-10 16:24:30 +0200
committerJordan Demeulenaere <jdemeulenaere@google.com>2022-06-10 14:26:55 +0000
commit4149cdeb0128facacfb2d09ddcfa0661259c177f (patch)
treedffdf7e0d49949b39f154d2070eefb7bce140ad6
parentde088d407c7ca6bb682527e8e802242668813ed4 (diff)
downloadktlint-4149cdeb0128facacfb2d09ddcfa0661259c177f.tar.gz
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
-rwxr-xr-xktlint.py5
1 files 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']