Christoffer Quist Adamsen | 3d14bf2 | 2020-03-19 09:40:47 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import subprocess |
| 8 | import sys |
| 9 | |
| 10 | import utils |
| 11 | |
| 12 | from subprocess import Popen, PIPE |
| 13 | |
| 14 | GOOGLE_JAVA_FORMAT_DIFF = os.path.join( |
| 15 | utils.THIRD_PARTY, |
| 16 | 'google-java-format', |
| 17 | 'google-java-format-google-java-format-1.7', |
| 18 | 'scripts', |
| 19 | 'google-java-format-diff.py') |
| 20 | |
| 21 | def main(): |
| 22 | upstream = subprocess.check_output(['git', 'cl', 'upstream']).strip() |
| 23 | git_diff_process = Popen(['git', 'diff', '-U0', upstream], stdout=PIPE) |
| 24 | fmt_process = Popen( |
| 25 | ['python', GOOGLE_JAVA_FORMAT_DIFF, '-p1', '-i'], |
| 26 | stdin=git_diff_process.stdout) |
| 27 | git_diff_process.stdout.close() |
| 28 | fmt_process.communicate() |
| 29 | |
| 30 | if __name__ == '__main__': |
| 31 | sys.exit(main()) |