aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrameet Shah <phshah@google.com>2017-11-27 13:19:10 -0800
committerPrameet Shah <phshah@google.com>2017-11-27 22:01:38 +0000
commitcc9b46c682c9fe1669e44c6b56f649cfdd6e3ceb (patch)
tree87bc738f6efbabf5b2c21c1574b68f124214300d
parent9e01ab18dc9589d5a802a134bfa5800bb8dff580 (diff)
downloadrepohooks-cc9b46c682c9fe1669e44c6b56f649cfdd6e3ceb.tar.gz
Allow users to specify list of files/path to google-java-formatandroid-o-mr1-iot-preview-6o-mr1-iot-preview-6
Bug: 69068870 Test: Ran "repo upload" and verified that google-java-format runs on all modified files when a list of files/path is not specified. Test: Ran "repo upload" and verified that google-java-format runs on all modified files from a list of files/path. Change-Id: Ib07c9fa81ffbcf7ef38feaf6ea40b321c701f998
-rwxr-xr-xtools/google-java-format.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/google-java-format.py b/tools/google-java-format.py
index b0b164c..0022c9d 100755
--- a/tools/google-java-format.py
+++ b/tools/google-java-format.py
@@ -52,6 +52,9 @@ def get_parser():
# default to not sort imports, while letting callers override as desired.
parser.add_argument('--sort-imports', action='store_true',
help='If true, imports will be sorted.')
+ parser.add_argument('files', nargs='*',
+ help='If specified, only consider differences in '
+ 'these files.')
return parser
@@ -79,6 +82,7 @@ def main(argv):
# TODO: Delegate to the tool once this issue is resolved:
# https://github.com/google/google-java-format/issues/107
diff_cmd = ['git', 'diff', '--no-ext-diff', '-U0', '%s^!' % opts.commit]
+ diff_cmd.extend(['--'] + opts.files)
diff = rh.utils.run_command(diff_cmd, capture_output=True).output
cmd = [opts.google_java_format_diff, '-p1', '--aosp']