blob: cda33f941efb1392965ae604334c9fb525397ed2 [file] [log] [blame]
Christoffer Quist Adamsenbfe52fd2022-02-15 14:32:52 +01001#!/usr/bin/env python3
Christoffer Quist Adamsen3d14bf22020-03-19 09:40:47 +01002# 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,
Christoffer Quist Adamsenbfe52fd2022-02-15 14:32:52 +010016 'google',
Christoffer Quist Adamsen3d14bf22020-03-19 09:40:47 +010017 'google-java-format',
Christoffer Quist Adamsenbfe52fd2022-02-15 14:32:52 +010018 '1.14.0',
19 'google-java-format-1.14.0',
Christoffer Quist Adamsen3d14bf22020-03-19 09:40:47 +010020 'scripts',
21 'google-java-format-diff.py')
22
23def main():
24 upstream = subprocess.check_output(['git', 'cl', 'upstream']).strip()
25 git_diff_process = Popen(['git', 'diff', '-U0', upstream], stdout=PIPE)
26 fmt_process = Popen(
Christoffer Quist Adamsenf3069c82021-09-30 13:57:52 +020027 [sys.executable, GOOGLE_JAVA_FORMAT_DIFF, '-p1', '-i'],
Christoffer Quist Adamsen3d14bf22020-03-19 09:40:47 +010028 stdin=git_diff_process.stdout)
29 git_diff_process.stdout.close()
30 fmt_process.communicate()
31
32if __name__ == '__main__':
33 sys.exit(main())