blob: 4e97f3a6561bde8cd19df495acf3493bb3e47804 [file] [log] [blame]
Christoffer Quist Adamsen3d14bf22020-03-19 09:40:47 +01001#!/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
6import os
7import subprocess
8import sys
9
10import utils
11
12from subprocess import Popen, PIPE
13
14GOOGLE_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
21def 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
30if __name__ == '__main__':
31 sys.exit(main())