OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 errno | 10 import errno |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 RunGit(['config', self._IssueSetting(), str(issue)]) | 506 RunGit(['config', self._IssueSetting(), str(issue)]) |
507 if self.rietveld_server: | 507 if self.rietveld_server: |
508 RunGit(['config', self._RietveldServer(), self.rietveld_server]) | 508 RunGit(['config', self._RietveldServer(), self.rietveld_server]) |
509 else: | 509 else: |
510 RunGit(['config', '--unset', self._IssueSetting()]) | 510 RunGit(['config', '--unset', self._IssueSetting()]) |
511 self.SetPatchset(0) | 511 self.SetPatchset(0) |
512 self.has_issue = False | 512 self.has_issue = False |
513 | 513 |
514 def RunHook(self, committing, upstream_branch, tbr, may_prompt, verbose): | 514 def RunHook(self, committing, upstream_branch, tbr, may_prompt, verbose): |
515 """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" | 515 """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" |
516 root = RunCommand(['git', 'rev-parse', '--show-cdup']).strip() | 516 root = RunCommand(['git', 'rev-parse', '--show-cdup']).strip() or '.' |
517 absroot = os.path.abspath(root or '.') | 517 absroot = os.path.abspath(root) |
518 | 518 |
519 # We use the sha1 of HEAD as a name of this change. | 519 # We use the sha1 of HEAD as a name of this change. |
520 name = RunCommand(['git', 'rev-parse', 'HEAD']).strip() | 520 name = RunCommand(['git', 'rev-parse', 'HEAD']).strip() |
521 files = scm.GIT.CaptureStatus([absroot], upstream_branch) | 521 # Need to pass a relative path for msysgit. |
| 522 files = scm.GIT.CaptureStatus([root], upstream_branch) |
522 | 523 |
523 issue = ConvertToInteger(self.GetIssue()) | 524 issue = ConvertToInteger(self.GetIssue()) |
524 patchset = ConvertToInteger(self.GetPatchset()) | 525 patchset = ConvertToInteger(self.GetPatchset()) |
525 if issue: | 526 if issue: |
526 description = self.GetDescription() | 527 description = self.GetDescription() |
527 else: | 528 else: |
528 # If the change was never uploaded, use the log messages of all commits | 529 # If the change was never uploaded, use the log messages of all commits |
529 # up to the branch point, as git cl upload will prefill the description | 530 # up to the branch point, as git cl upload will prefill the description |
530 # with these log messages. | 531 # with these log messages. |
531 description = RunCommand(['git', 'log', '--pretty=format:%s%n%n%b', | 532 description = RunCommand(['git', 'log', '--pretty=format:%s%n%n%b', |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1444 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1444 | 1445 |
1445 # Not a known command. Default to help. | 1446 # Not a known command. Default to help. |
1446 GenUsage(parser, 'help') | 1447 GenUsage(parser, 'help') |
1447 return CMDhelp(parser, argv) | 1448 return CMDhelp(parser, argv) |
1448 | 1449 |
1449 | 1450 |
1450 if __name__ == '__main__': | 1451 if __name__ == '__main__': |
1451 fix_encoding.fix_encoding() | 1452 fix_encoding.fix_encoding() |
1452 sys.exit(main(sys.argv[1:])) | 1453 sys.exit(main(sys.argv[1:])) |
OLD | NEW |