diff options
| -rw-r--r-- | project.py | 21 | ||||
| -rw-r--r-- | subcmds/upload.py | 15 |
2 files changed, 36 insertions, 0 deletions
| @@ -368,6 +368,27 @@ class Project(object): | |||
| 368 | 368 | ||
| 369 | ## Status Display ## | 369 | ## Status Display ## |
| 370 | 370 | ||
| 371 | def HasChanges(self): | ||
| 372 | """Returns true if there are uncommitted changes. | ||
| 373 | """ | ||
| 374 | self.work_git.update_index('-q', | ||
| 375 | '--unmerged', | ||
| 376 | '--ignore-missing', | ||
| 377 | '--refresh') | ||
| 378 | if self.IsRebaseInProgress(): | ||
| 379 | return True | ||
| 380 | |||
| 381 | if self.work_git.DiffZ('diff-index', '--cached', HEAD): | ||
| 382 | return True | ||
| 383 | |||
| 384 | if self.work_git.DiffZ('diff-files'): | ||
| 385 | return True | ||
| 386 | |||
| 387 | if self.work_git.LsOthers(): | ||
| 388 | return True | ||
| 389 | |||
| 390 | return False | ||
| 391 | |||
| 371 | def PrintWorkTreeStatus(self): | 392 | def PrintWorkTreeStatus(self): |
| 372 | """Prints the status of the repository to stdout. | 393 | """Prints the status of the repository to stdout. |
| 373 | """ | 394 | """ |
diff --git a/subcmds/upload.py b/subcmds/upload.py index ba532461..5a426113 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -320,6 +320,21 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 320 | people = copy.deepcopy(original_people) | 320 | people = copy.deepcopy(original_people) |
| 321 | self._AppendAutoCcList(branch, people) | 321 | self._AppendAutoCcList(branch, people) |
| 322 | 322 | ||
| 323 | # Check if there are local changes that may have been forgotten | ||
| 324 | if branch.project.HasChanges(): | ||
| 325 | key = 'review.%s.autoupload' % branch.project.remote.review | ||
| 326 | answer = branch.project.config.GetBoolean(key) | ||
| 327 | |||
| 328 | # if they want to auto upload, let's not ask because it could be automated | ||
| 329 | if answer is None: | ||
| 330 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/n) ') | ||
| 331 | a = sys.stdin.readline().strip().lower() | ||
| 332 | if a not in ('y', 'yes', 't', 'true', 'on'): | ||
| 333 | print >>sys.stderr, "skipping upload" | ||
| 334 | branch.uploaded = False | ||
| 335 | branch.error = 'User aborted' | ||
| 336 | continue | ||
| 337 | |||
| 323 | branch.UploadForReview(people) | 338 | branch.UploadForReview(people) |
| 324 | branch.uploaded = True | 339 | branch.uploaded = True |
| 325 | except UploadError, e: | 340 | except UploadError, e: |
