| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
| 9 | 9 |
| 10 from __future__ import print_function | 10 from __future__ import print_function |
| (...skipping 4774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4785 return diff_cmd | 4785 return diff_cmd |
| 4786 | 4786 |
| 4787 def MatchingFileType(file_name, extensions): | 4787 def MatchingFileType(file_name, extensions): |
| 4788 """Returns true if the file name ends with one of the given extensions.""" | 4788 """Returns true if the file name ends with one of the given extensions.""" |
| 4789 return bool([ext for ext in extensions if file_name.lower().endswith(ext)]) | 4789 return bool([ext for ext in extensions if file_name.lower().endswith(ext)]) |
| 4790 | 4790 |
| 4791 @subcommand.usage('[files or directories to diff]') | 4791 @subcommand.usage('[files or directories to diff]') |
| 4792 def CMDformat(parser, args): | 4792 def CMDformat(parser, args): |
| 4793 """Runs auto-formatting tools (clang-format etc.) on the diff.""" | 4793 """Runs auto-formatting tools (clang-format etc.) on the diff.""" |
| 4794 CLANG_EXTS = ['.cc', '.cpp', '.h', '.mm', '.proto', '.java'] | 4794 CLANG_EXTS = ['.cc', '.cpp', '.h', '.mm', '.proto', '.java'] |
| 4795 GN_EXTS = ['.gn', '.gni'] | 4795 GN_EXTS = ['.gn', '.gni', '.typemap'] |
| 4796 parser.add_option('--full', action='store_true', | 4796 parser.add_option('--full', action='store_true', |
| 4797 help='Reformat the full content of all touched files') | 4797 help='Reformat the full content of all touched files') |
| 4798 parser.add_option('--dry-run', action='store_true', | 4798 parser.add_option('--dry-run', action='store_true', |
| 4799 help='Don\'t modify any file on disk.') | 4799 help='Don\'t modify any file on disk.') |
| 4800 parser.add_option('--python', action='store_true', | 4800 parser.add_option('--python', action='store_true', |
| 4801 help='Format python code with yapf (experimental).') | 4801 help='Format python code with yapf (experimental).') |
| 4802 parser.add_option('--diff', action='store_true', | 4802 parser.add_option('--diff', action='store_true', |
| 4803 help='Print diff to stdout rather than modifying files.') | 4803 help='Print diff to stdout rather than modifying files.') |
| 4804 opts, args = parser.parse_args(args) | 4804 opts, args = parser.parse_args(args) |
| 4805 | 4805 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5029 if __name__ == '__main__': | 5029 if __name__ == '__main__': |
| 5030 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5030 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5031 # unit testing. | 5031 # unit testing. |
| 5032 fix_encoding.fix_encoding() | 5032 fix_encoding.fix_encoding() |
| 5033 setup_color.init() | 5033 setup_color.init() |
| 5034 try: | 5034 try: |
| 5035 sys.exit(main(sys.argv[1:])) | 5035 sys.exit(main(sys.argv[1:])) |
| 5036 except KeyboardInterrupt: | 5036 except KeyboardInterrupt: |
| 5037 sys.stderr.write('interrupted\n') | 5037 sys.stderr.write('interrupted\n') |
| 5038 sys.exit(1) | 5038 sys.exit(1) |
| OLD | NEW |