Revert "Add --push-options in git cl upload"
This reverts commit e2c65d7b75cb358c0b75c9668b075f821d03e0aa.
Reason for revert: https://crbug.com/1192942
Original change's description:
> Add --push-options in git cl upload
>
> --push-option parameter is passed to git push as is.
>
> R=​ehmaldonado@google.com
>
> Bug: 1184393
> Change-Id: Id1f7da1f0c8e8a23144b547d50d817fe8d4efeb1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2786080
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Bug: 1184393
Change-Id: Idf5d79fda3c5f917b1de5ca396837f14a401ffb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2791749
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
diff --git a/git_cl.py b/git_cl.py
index e343cfc..4f248fc 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2166,10 +2166,7 @@
gclient_utils.rmtree(git_info_dir)
- def _RunGitPushWithTraces(self,
- refspec,
- push_options,
- git_push_metadata):
+ def _RunGitPushWithTraces(self, refspec, refspec_opts, git_push_metadata):
"""Run git push and collect the traces resulting from the execution."""
# Create a temporary directory to store traces in. Traces will be compressed
# and stored in a 'traces' dir inside depot_tools.
@@ -2189,12 +2186,8 @@
push_returncode = 0
remote_url = self.GetRemoteUrl()
before_push = time_time()
- push_cmd = ['git', 'push', remote_url, refspec]
- for opt in push_options:
- push_cmd.extend(['-o', opt])
-
push_stdout = gclient_utils.CheckCallAndFilter(
- push_cmd,
+ ['git', 'push', remote_url, refspec],
env=env,
print_stdout=True,
# Flush after every line: useful for seeing progress when running as
@@ -2224,7 +2217,7 @@
'command': 'git push',
'execution_time': execution_time,
'exit_code': push_returncode,
- 'arguments': metrics_utils.extract_known_subcommand_args(push_options),
+ 'arguments': metrics_utils.extract_known_subcommand_args(refspec_opts),
})
git_push_metadata['execution_time'] = execution_time
@@ -2349,18 +2342,18 @@
# Extra options that can be specified at push time. Doc:
# https://gerrit-review.googlesource.com/Documentation/user-upload.html
- push_options = options.push_options if options.push_options else []
+ refspec_opts = []
# By default, new changes are started in WIP mode, and subsequent patchsets
# don't send email. At any time, passing --send-mail will mark the change
# ready and send email for that particular patch.
if options.send_mail:
- push_options.append('ready')
- push_options.append('notify=ALL')
+ refspec_opts.append('ready')
+ refspec_opts.append('notify=ALL')
elif not self.GetIssue() and options.squash:
- push_options.append('wip')
+ refspec_opts.append('wip')
else:
- push_options.append('notify=NONE')
+ refspec_opts.append('notify=NONE')
# TODO(tandrii): options.message should be posted as a comment
# if --send-mail is set on non-initial upload as Rietveld used to do it.
@@ -2370,15 +2363,15 @@
options.title = self._GetTitleForUpload(options)
if options.title:
# Punctuation and whitespace in |title| must be percent-encoded.
- push_options.append(
+ refspec_opts.append(
'm=' + gerrit_util.PercentEncodeForGitRef(options.title))
if options.private:
- push_options.append('private')
+ refspec_opts.append('private')
for r in sorted(reviewers):
if r in valid_accounts:
- push_options.append('r=%s' % r)
+ refspec_opts.append('r=%s' % r)
reviewers.remove(r)
else:
# TODO(tandrii): this should probably be a hard failure.
@@ -2388,34 +2381,41 @@
# refspec option will be rejected if cc doesn't correspond to an
# account, even though REST call to add such arbitrary cc may succeed.
if c in valid_accounts:
- push_options.append('cc=%s' % c)
+ refspec_opts.append('cc=%s' % c)
cc.remove(c)
if options.topic:
# Documentation on Gerrit topics is here:
# https://gerrit-review.googlesource.com/Documentation/user-upload.html#topic
- push_options.append('topic=%s' % options.topic)
+ refspec_opts.append('topic=%s' % options.topic)
if options.enable_auto_submit:
- push_options.append('l=Auto-Submit+1')
+ refspec_opts.append('l=Auto-Submit+1')
if options.set_bot_commit:
- push_options.append('l=Bot-Commit+1')
+ refspec_opts.append('l=Bot-Commit+1')
if options.use_commit_queue:
- push_options.append('l=Commit-Queue+2')
+ refspec_opts.append('l=Commit-Queue+2')
elif options.cq_dry_run:
- push_options.append('l=Commit-Queue+1')
+ refspec_opts.append('l=Commit-Queue+1')
if change_desc.get_reviewers(tbr_only=True):
score = gerrit_util.GetCodeReviewTbrScore(
self.GetGerritHost(),
self.GetGerritProject())
- push_options.append('l=Code-Review+%s' % score)
+ refspec_opts.append('l=Code-Review+%s' % score)
# Gerrit sorts hashtags, so order is not important.
hashtags = {change_desc.sanitize_hash_tag(t) for t in options.hashtags}
if not self.GetIssue():
hashtags.update(change_desc.get_hash_tags())
- push_options += ['hashtag=%s' % t for t in sorted(hashtags)]
+ refspec_opts += ['hashtag=%s' % t for t in sorted(hashtags)]
+
+ refspec_suffix = ''
+ if refspec_opts:
+ refspec_suffix = '%' + ','.join(refspec_opts)
+ assert ' ' not in refspec_suffix, (
+ 'spaces not allowed in refspec: "%s"' % refspec_suffix)
+ refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix)
git_push_metadata = {
'gerrit_host': self.GetGerritHost(),
@@ -2423,11 +2423,8 @@
'change_id': change_id,
'description': change_desc.description,
}
-
- push_stdout = self._RunGitPushWithTraces(
- '%s:refs/for/%s' % (ref_to_push, branch),
- push_options,
- git_push_metadata)
+ push_stdout = self._RunGitPushWithTraces(refspec, refspec_opts,
+ git_push_metadata)
if options.squash:
regex = re.compile(r'remote:\s+https?://[\w\-\.\+\/#]*/(\d+)\s.*')
@@ -4195,10 +4192,6 @@
help='Run presubmit checks in the ResultSink environment '
'and send results to the ResultDB database.')
parser.add_option('--realm', help='LUCI realm if reporting to ResultDB')
- parser.add_option('-o', '--push-options', action='append', default=[],
- help='Transmit the given string to the server when '
- 'performing git push (pass-through). See git-push '
- 'documentation for more details.')
orig_args = args
(options, args) = parser.parse_args(args)