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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 import json | 10 import json |
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 | 1957 |
1958 def CMDformat(parser, args): | 1958 def CMDformat(parser, args): |
1959 """run clang-format on the diff""" | 1959 """run clang-format on the diff""" |
1960 CLANG_EXTS = ['.cc', '.cpp', '.h'] | 1960 CLANG_EXTS = ['.cc', '.cpp', '.h'] |
1961 parser.add_option('--full', action='store_true', default=False) | 1961 parser.add_option('--full', action='store_true', default=False) |
1962 opts, args = parser.parse_args(args) | 1962 opts, args = parser.parse_args(args) |
1963 if args: | 1963 if args: |
1964 parser.error('Unrecognized args: %s' % ' '.join(args)) | 1964 parser.error('Unrecognized args: %s' % ' '.join(args)) |
1965 | 1965 |
1966 # Generate diff for the current branch's changes. | 1966 # Generate diff for the current branch's changes. |
1967 diff_cmd = ['diff', '--no-ext-diff'] | 1967 diff_cmd = ['diff', '--no-ext-diff', '--no-prefix'] |
1968 if opts.full: | 1968 if opts.full: |
1969 # Only list the names of modified files. | 1969 # Only list the names of modified files. |
1970 diff_cmd.append('--name-only') | 1970 diff_cmd.append('--name-only') |
1971 else: | 1971 else: |
1972 # Only generate context-less patches. | 1972 # Only generate context-less patches. |
1973 diff_cmd.append('-U0') | 1973 diff_cmd.append('-U0') |
1974 | 1974 |
1975 # Grab the merge-base commit, i.e. the upstream commit of the current | 1975 # Grab the merge-base commit, i.e. the upstream commit of the current |
1976 # branch when it was created or the last time it was rebased. This is | 1976 # branch when it was created or the last time it was rebased. This is |
1977 # to cover the case where the user may have called "git fetch origin", | 1977 # to cover the case where the user may have called "git fetch origin", |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 GenUsage(parser, 'help') | 2091 GenUsage(parser, 'help') |
2092 return CMDhelp(parser, argv) | 2092 return CMDhelp(parser, argv) |
2093 | 2093 |
2094 | 2094 |
2095 if __name__ == '__main__': | 2095 if __name__ == '__main__': |
2096 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2096 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2097 # unit testing. | 2097 # unit testing. |
2098 fix_encoding.fix_encoding() | 2098 fix_encoding.fix_encoding() |
2099 colorama.init() | 2099 colorama.init() |
2100 sys.exit(main(sys.argv[1:])) | 2100 sys.exit(main(sys.argv[1:])) |
OLD | NEW |