summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2014-10-05 15:40:30 -0700
committerVadim Bendebury <vbendeb@google.com>2014-10-14 11:20:05 -0700
commit14e134da02f3c050c9a6ec31242b45e27bdf4821 (patch)
treef6c417df0dfbb5799a2406fbae206be64a0d3214 /project.py
parent5cf16607d33268ab0320a886c4a7b5e052684fa4 (diff)
downloadgit-repo-14e134da02f3c050c9a6ec31242b45e27bdf4821.tar.gz
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>
Diffstat (limited to 'project.py')
-rw-r--r--project.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/project.py b/project.py
index 95403ccb..316ce7ba 100644
--- a/project.py
+++ b/project.py
@@ -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.