mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
upload: report names of uncommitted files
When there are uncommitted files in the tree, 'repo upload' stops to ask if it is OK to continue, but does not report the actual names of uncommitted files. This patch adds plumbing to have the outstanding file names reported if desired. BUG=None TEST=verified that 'repo upload' properly operates with the following conditions present in the tree: . file(s) modified locally . file(s) added to index, but not committed . files not known to git . no modified files (the upload proceeds as expected) Change-Id: If65d5f8e8bcb3300c16d85dc5d7017758545f80d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Signed-off-by: Vadim Bendebury <vbendeb@google.com>
This commit is contained in:
parent
5cf16607d3
commit
14e134da02
42
project.py
42
project.py
@ -736,27 +736,49 @@ class Project(object):
|
||||
return matched
|
||||
|
||||
## Status Display ##
|
||||
def UncommitedFiles(self, get_all=True):
|
||||
"""Returns a list of strings, uncommitted files in the git tree.
|
||||
|
||||
def HasChanges(self):
|
||||
"""Returns true if there are uncommitted changes.
|
||||
Args:
|
||||
get_all: a boolean, if True - get information about all different
|
||||
uncommitted files. If False - return as soon as any kind of
|
||||
uncommitted files is detected.
|
||||
"""
|
||||
details = []
|
||||
self.work_git.update_index('-q',
|
||||
'--unmerged',
|
||||
'--ignore-missing',
|
||||
'--refresh')
|
||||
if self.IsRebaseInProgress():
|
||||
return True
|
||||
details.append("rebase in progress")
|
||||
if not get_all:
|
||||
return details
|
||||
|
||||
if self.work_git.DiffZ('diff-index', '--cached', HEAD):
|
||||
return True
|
||||
changes = self.work_git.DiffZ('diff-index', '--cached', HEAD).keys()
|
||||
if changes:
|
||||
details.extend(changes)
|
||||
if not get_all:
|
||||
return details
|
||||
|
||||
if self.work_git.DiffZ('diff-files'):
|
||||
return True
|
||||
changes = self.work_git.DiffZ('diff-files').keys()
|
||||
if changes:
|
||||
details.extend(changes)
|
||||
if not get_all:
|
||||
return details
|
||||
|
||||
if self.work_git.LsOthers():
|
||||
return True
|
||||
changes = self.work_git.LsOthers()
|
||||
if changes:
|
||||
details.extend(changes)
|
||||
|
||||
return False
|
||||
return details
|
||||
|
||||
def HasChanges(self):
|
||||
"""Returns true if there are uncommitted changes.
|
||||
"""
|
||||
if self.UncommitedFiles(get_all=False):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def PrintWorkTreeStatus(self, output_redir=None):
|
||||
"""Prints the status of the repository to stdout.
|
||||
|
@ -339,13 +339,17 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
||||
self._AppendAutoList(branch, people)
|
||||
|
||||
# Check if there are local changes that may have been forgotten
|
||||
if branch.project.HasChanges():
|
||||
changes = branch.project.UncommitedFiles()
|
||||
if changes:
|
||||
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) ')
|
||||
sys.stdout.write('Uncommitted changes in ' + branch.project.name)
|
||||
sys.stdout.write(' (did you forget to amend?):\n')
|
||||
sys.stdout.write('\n'.join(changes) + '\n')
|
||||
sys.stdout.write('Continue uploading? (y/N) ')
|
||||
a = sys.stdin.readline().strip().lower()
|
||||
if a not in ('y', 'yes', 't', 'true', 'on'):
|
||||
print("skipping upload", file=sys.stderr)
|
||||
|
Loading…
Reference in New Issue
Block a user