mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Warn users before uploading if there are local changes
Change-Id: I231d7b6a3211e9f5ec71a542a0109b0c195d5e40 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
0cb1b3f687
commit
cc50bac8c7
21
project.py
21
project.py
@ -368,6 +368,27 @@ class Project(object):
|
|||||||
|
|
||||||
## Status Display ##
|
## Status Display ##
|
||||||
|
|
||||||
|
def HasChanges(self):
|
||||||
|
"""Returns true if there are uncommitted changes.
|
||||||
|
"""
|
||||||
|
self.work_git.update_index('-q',
|
||||||
|
'--unmerged',
|
||||||
|
'--ignore-missing',
|
||||||
|
'--refresh')
|
||||||
|
if self.IsRebaseInProgress():
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.work_git.DiffZ('diff-index', '--cached', HEAD):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.work_git.DiffZ('diff-files'):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.work_git.LsOthers():
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def PrintWorkTreeStatus(self):
|
def PrintWorkTreeStatus(self):
|
||||||
"""Prints the status of the repository to stdout.
|
"""Prints the status of the repository to stdout.
|
||||||
"""
|
"""
|
||||||
|
@ -320,6 +320,21 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
people = copy.deepcopy(original_people)
|
people = copy.deepcopy(original_people)
|
||||||
self._AppendAutoCcList(branch, people)
|
self._AppendAutoCcList(branch, people)
|
||||||
|
|
||||||
|
# Check if there are local changes that may have been forgotten
|
||||||
|
if branch.project.HasChanges():
|
||||||
|
key = 'review.%s.autoupload' % branch.project.remote.review
|
||||||
|
answer = branch.project.config.GetBoolean(key)
|
||||||
|
|
||||||
|
# if they want to auto upload, let's not ask because it could be automated
|
||||||
|
if answer is None:
|
||||||
|
sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/n) ')
|
||||||
|
a = sys.stdin.readline().strip().lower()
|
||||||
|
if a not in ('y', 'yes', 't', 'true', 'on'):
|
||||||
|
print >>sys.stderr, "skipping upload"
|
||||||
|
branch.uploaded = False
|
||||||
|
branch.error = 'User aborted'
|
||||||
|
continue
|
||||||
|
|
||||||
branch.UploadForReview(people)
|
branch.UploadForReview(people)
|
||||||
branch.uploaded = True
|
branch.uploaded = True
|
||||||
except UploadError, e:
|
except UploadError, e:
|
||||||
|
Loading…
Reference in New Issue
Block a user