diff options
| -rw-r--r-- | project.py | 42 | ||||
| -rw-r--r-- | subcmds/upload.py | 8 |
2 files changed, 38 insertions, 12 deletions
| @@ -736,27 +736,49 @@ class Project(object): | |||
| 736 | return matched | 736 | return matched |
| 737 | 737 | ||
| 738 | ## Status Display ## | 738 | ## Status Display ## |
| 739 | def UncommitedFiles(self, get_all=True): | ||
| 740 | """Returns a list of strings, uncommitted files in the git tree. | ||
| 739 | 741 | ||
| 740 | def HasChanges(self): | 742 | Args: |
| 741 | """Returns true if there are uncommitted changes. | 743 | get_all: a boolean, if True - get information about all different |
| 744 | uncommitted files. If False - return as soon as any kind of | ||
| 745 | uncommitted files is detected. | ||
| 742 | """ | 746 | """ |
| 747 | details = [] | ||
| 743 | self.work_git.update_index('-q', | 748 | self.work_git.update_index('-q', |
| 744 | '--unmerged', | 749 | '--unmerged', |
| 745 | '--ignore-missing', | 750 | '--ignore-missing', |
| 746 | '--refresh') | 751 | '--refresh') |
| 747 | if self.IsRebaseInProgress(): | 752 | if self.IsRebaseInProgress(): |
| 748 | return True | 753 | details.append("rebase in progress") |
| 754 | if not get_all: | ||
| 755 | return details | ||
| 749 | 756 | ||
| 750 | if self.work_git.DiffZ('diff-index', '--cached', HEAD): | 757 | changes = self.work_git.DiffZ('diff-index', '--cached', HEAD).keys() |
| 751 | return True | 758 | if changes: |
| 759 | details.extend(changes) | ||
| 760 | if not get_all: | ||
| 761 | return details | ||
| 752 | 762 | ||
| 753 | if self.work_git.DiffZ('diff-files'): | 763 | changes = self.work_git.DiffZ('diff-files').keys() |
| 754 | return True | 764 | if changes: |
| 765 | details.extend(changes) | ||
| 766 | if not get_all: | ||
| 767 | return details | ||
| 755 | 768 | ||
| 756 | if self.work_git.LsOthers(): | 769 | changes = self.work_git.LsOthers() |
| 757 | return True | 770 | if changes: |
| 771 | details.extend(changes) | ||
| 758 | 772 | ||
| 759 | return False | 773 | return details |
| 774 | |||
| 775 | def HasChanges(self): | ||
| 776 | """Returns true if there are uncommitted changes. | ||
| 777 | """ | ||
| 778 | if self.UncommitedFiles(get_all=False): | ||
| 779 | return True | ||
| 780 | else: | ||
| 781 | return False | ||
| 760 | 782 | ||
| 761 | def PrintWorkTreeStatus(self, output_redir=None): | 783 | def PrintWorkTreeStatus(self, output_redir=None): |
| 762 | """Prints the status of the repository to stdout. | 784 | """Prints the status of the repository to stdout. |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 0ee36df1..674fc17d 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -339,13 +339,17 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 339 | self._AppendAutoList(branch, people) | 339 | self._AppendAutoList(branch, people) |
| 340 | 340 | ||
| 341 | # Check if there are local changes that may have been forgotten | 341 | # Check if there are local changes that may have been forgotten |
| 342 | if branch.project.HasChanges(): | 342 | changes = branch.project.UncommitedFiles() |
| 343 | if changes: | ||
| 343 | key = 'review.%s.autoupload' % branch.project.remote.review | 344 | key = 'review.%s.autoupload' % branch.project.remote.review |
| 344 | answer = branch.project.config.GetBoolean(key) | 345 | answer = branch.project.config.GetBoolean(key) |
| 345 | 346 | ||
| 346 | # if they want to auto upload, let's not ask because it could be automated | 347 | # if they want to auto upload, let's not ask because it could be automated |
| 347 | if answer is None: | 348 | if answer is None: |
| 348 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') | 349 | sys.stdout.write('Uncommitted changes in ' + branch.project.name) |
| 350 | sys.stdout.write(' (did you forget to amend?):\n') | ||
| 351 | sys.stdout.write('\n'.join(changes) + '\n') | ||
| 352 | sys.stdout.write('Continue uploading? (y/N) ') | ||
| 349 | a = sys.stdin.readline().strip().lower() | 353 | a = sys.stdin.readline().strip().lower() |
| 350 | if a not in ('y', 'yes', 't', 'true', 'on'): | 354 | if a not in ('y', 'yes', 't', 'true', 'on'): |
| 351 | print("skipping upload", file=sys.stderr) | 355 | print("skipping upload", file=sys.stderr) |
