Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: git_cl.py

Issue 1584703005: Add a setting to squash Gerrit uploads by default, and a --no-squash command line option to overrid… (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: x Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 49bed386baa821cfedf4370030bc9cb1b6afb452..34c72b9f432712403c182f33f5a91808f25febe9 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -433,6 +433,7 @@ class Settings(object):
self.viewvc_url = None
self.updated = False
self.is_gerrit = None
+ self.squash_gerrit_uploads = None
self.git_editor = None
self.project = None
self.force_https_commit_url = None
@@ -598,6 +599,14 @@ class Settings(object):
self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True)
return self.is_gerrit
+ def GetSquashGerritUploads(self):
+ """Return true if uploads to Gerrit should be squashed by default."""
+ if self.squash_gerrit_uploads is None:
+ self.squash_gerrit_uploads = (
+ RunGit(['config', '--bool', 'gerrit.squash-uploads'],
+ error_ok=True).strip() == 'true')
+ return self.squash_gerrit_uploads
+
def GetGitEditor(self):
"""Return the editor specified in the git config, or None if none is."""
if self.git_editor is None:
@@ -1386,6 +1395,10 @@ def LoadCodereviewSettingsFromFile(fileobj):
if 'GERRIT_HOST' in keyvals:
RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
+ if 'GERRIT_SQUASH_UPLOADS' in keyvals:
+ RunGit(['config', 'gerrit.squash-uploads',
+ keyvals['GERRIT_SQUASH_UPLOADS']])
+
if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals:
#should be of the form
#PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof
@@ -2353,6 +2366,9 @@ def CMDupload(parser, args):
'Default: remote branch head, or master')
parser.add_option('--squash', action='store_true',
help='Squash multiple commits into one (Gerrit only)')
+ parser.add_option('--no-squash', action='store_true',
+ help='Don\'t squash multiple commits into one ' +
+ '(Gerrit only)')
parser.add_option('--email', default=None,
help='email address to use to connect to Rietveld')
parser.add_option('--tbr-owners', dest='tbr_owners', action='store_true',
@@ -2436,6 +2452,12 @@ def CMDupload(parser, args):
print_stats(options.similarity, options.find_copies, args)
if settings.GetIsGerrit():
+ if options.squash and options.no_squash:
+ DieWithError('Can only use one of --squash or --no-squash')
+
+ options.squash = ((settings.GetSquashGerritUploads() or options.squash) and
+ not options.no_squash)
+
return GerritUpload(options, args, cl, change)
ret = RietveldUpload(options, args, cl, change)
if not ret:
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698