Skip to content

Commit 3fcb71a

Browse files
ngzhianronshapiro
authored andcommitted
Add flag to specify path to google-java-format binary in google-java-format-diff.py
Fixes #44 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218737500
1 parent 92e0dfc commit 3fcb71a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/google-java-format-diff.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import sys
3232
from distutils.spawn import find_executable
3333

34-
binary = find_executable('google-java-format') or '/usr/bin/google-java-format'
35-
3634
def main():
3735
parser = argparse.ArgumentParser(description=
3836
'Reformat changed lines in diff. Without -i '
@@ -55,6 +53,7 @@ def main():
5553
help='use AOSP style instead of Google Style (4-space indentation)')
5654
parser.add_argument('--skip-sorting-imports', action='store_true',
5755
help='do not fix the import order')
56+
parser.add_argument('-b', '--binary', help='path to google-java-format binary')
5857
args = parser.parse_args()
5958

6059
# Extract changed lines for each file.
@@ -87,6 +86,11 @@ def main():
8786
lines_by_file.setdefault(filename, []).extend(
8887
['-lines', str(start_line) + ':' + str(end_line)])
8988

89+
if args.binary:
90+
binary = args.binary
91+
else:
92+
binary = find_executable('google-java-format') or '/usr/bin/google-java-format'
93+
9094
# Reformat files containing changes in place.
9195
for filename, lines in lines_by_file.iteritems():
9296
if args.i and args.verbose:

0 commit comments

Comments
 (0)