summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Geisler <mgeisler@google.com>2022-07-08 10:50:10 +0200
committerMartin Geisler <mgeisler@google.com>2022-07-11 17:57:43 +0000
commit9fb64ae29cb978f869de5ff11a47f86e070b4274 (patch)
tree91254b0a4dc779f1db2ed24a9a2f679539173b5c
parentd47d9ff1cbb33da4b3e37bc524c58feef6866b7a (diff)
downloadgit-repo-9fb64ae29cb978f869de5ff11a47f86e070b4274.tar.gz
upload: add ‘--ignore-untracked-files’ option
This option will suppress the Uncommitted changes in ... (did you forget to amend?) prompt when there are untracked (unknown) files in the working copy. The prompt is still shown if tracked files are modified. Change-Id: Ia3fcc82989b7fad09b69214eda31e2d0dfc14600 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/340456 Tested-by: Martin Geisler <mgeisler@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
-rw-r--r--project.py8
-rw-r--r--subcmds/upload.py10
2 files changed, 16 insertions, 2 deletions
diff --git a/project.py b/project.py
index 48cf08c6..8274f022 100644
--- a/project.py
+++ b/project.py
@@ -650,7 +650,7 @@ class Project(object):
650 return True 650 return True
651 if self.work_git.DiffZ('diff-files'): 651 if self.work_git.DiffZ('diff-files'):
652 return True 652 return True
653 if consider_untracked and self.work_git.LsOthers(): 653 if consider_untracked and self.UntrackedFiles():
654 return True 654 return True
655 return False 655 return False
656 656
@@ -779,12 +779,16 @@ class Project(object):
779 if not get_all: 779 if not get_all:
780 return details 780 return details
781 781
782 changes = self.work_git.LsOthers() 782 changes = self.UntrackedFiles()
783 if changes: 783 if changes:
784 details.extend(changes) 784 details.extend(changes)
785 785
786 return details 786 return details
787 787
788 def UntrackedFiles(self):
789 """Returns a list of strings, untracked files in the git tree."""
790 return self.work_git.LsOthers()
791
788 def HasChanges(self): 792 def HasChanges(self):
789 """Returns true if there are uncommitted changes. 793 """Returns true if there are uncommitted changes.
790 """ 794 """
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 20b8fe5d..09ee5c02 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -204,6 +204,12 @@ Gerrit Code Review: https://www.gerritcodereview.com/
204 p.add_option('-y', '--yes', 204 p.add_option('-y', '--yes',
205 default=False, action='store_true', 205 default=False, action='store_true',
206 help='answer yes to all safe prompts') 206 help='answer yes to all safe prompts')
207 p.add_option('--ignore-untracked-files',
208 action='store_true', default=False,
209 help='ignore untracked files in the working copy')
210 p.add_option('--no-ignore-untracked-files',
211 dest='ignore_untracked_files', action='store_false',
212 help='always ask about untracked files in the working copy')
207 p.add_option('--no-cert-checks', 213 p.add_option('--no-cert-checks',
208 dest='validate_certs', action='store_false', default=True, 214 dest='validate_certs', action='store_false', default=True,
209 help='disable verifying ssl certs (unsafe)') 215 help='disable verifying ssl certs (unsafe)')
@@ -370,6 +376,10 @@ Gerrit Code Review: https://www.gerritcodereview.com/
370 376
371 # Check if there are local changes that may have been forgotten 377 # Check if there are local changes that may have been forgotten
372 changes = branch.project.UncommitedFiles() 378 changes = branch.project.UncommitedFiles()
379 if opt.ignore_untracked_files:
380 untracked = set(branch.project.UntrackedFiles())
381 changes = [x for x in changes if x not in untracked]
382
373 if changes: 383 if changes:
374 key = 'review.%s.autoupload' % branch.project.remote.review 384 key = 'review.%s.autoupload' % branch.project.remote.review
375 answer = branch.project.config.GetBoolean(key) 385 answer = branch.project.config.GetBoolean(key)