diff options
author | Jordan Demeulenaere <jdemeulenaere@google.com> | 2023-01-27 16:16:01 +0100 |
---|---|---|
committer | Jordan Demeulenaere <jdemeulenaere@google.com> | 2023-01-30 13:49:01 +0100 |
commit | dfe7dbe093486696f22f6ace921fc83a9de94bc8 (patch) | |
tree | 6689b48b354386d73a0c7d03de0930e8a851121c /ktfmt.py | |
parent | bdb0b8d3fa4d4442fde0d38193abda49271cdf61 (diff) | |
download | ktfmt-dfe7dbe093486696f22f6ace921fc83a9de94bc8.tar.gz |
Create a prepare_upgrade.sh script to help for upgrades
This CL introduces a helper script to make it easier to upgrade ktfmt.
It creates maximum 2 CLs per repository already using ktfmt:
- One that regenerates the ktfmt_includes.txt with the current version
of ktfmt, so that all files already properly formatted are checked
and files that are not already formatted are ignored. If the file is
already up-to-date, then this CL won't be created.
- One that reformats all files with the new version of ktfmt. This CL
won't be created if all files are already formatted.
See http://ag/21117371 and http://ag/21117372 for an example of
generated CLs.
Bug: 266197805
Test: Ran the script and it worked!
Change-Id: I6e86c71ead20ec65512202ef2b2900b41f8feb2c
Diffstat (limited to 'ktfmt.py')
-rwxr-xr-x | ktfmt.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -39,6 +39,11 @@ def main(): help='The file containing the Kotlin files and directories that should be included/excluded, generated using generate_includes_file.py.' ) parser.add_argument( + '--jar', + default='', + help='The path to the ktfmt jar.' + ) + parser.add_argument( 'files', nargs='*', help='The files to format or check. If --include_file is specified, only the files at their intersection will be formatted/checked.' @@ -91,8 +96,7 @@ def main(): ktfmt_args += kt_files dir = os.path.normpath(os.path.dirname(__file__)) - ktfmt_jar = os.path.join( - dir, '../../prebuilts/build-tools/common/framework/ktfmt.jar') + ktfmt_jar = args.jar if args.jar else os.path.join(dir, '../../prebuilts/build-tools/common/framework/ktfmt.jar') ktlint_env = os.environ.copy() ktlint_env['JAVA_CMD'] = 'java' |