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

Unified Diff: git_cherry_pick_upload.py

Issue 1075723002: Extract authentication options handling into a separate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 8 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 | « gcl.py ('k') | git_cl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cherry_pick_upload.py
diff --git a/git_cherry_pick_upload.py b/git_cherry_pick_upload.py
index 0bcb9fd926737e745fbca5b8d1408ad8f05b1f2d..3090364c6767c0e4a61989c54264d30594566e50 100755
--- a/git_cherry_pick_upload.py
+++ b/git_cherry_pick_upload.py
@@ -5,23 +5,26 @@
"""Upload a cherry pick CL to rietveld."""
-import argparse
import md5
+import optparse
import subprocess2
import sys
+import auth
+
from git_cl import Changelist
from git_common import config, run
from third_party.upload import EncodeMultipartFormData, GitVCS
from rietveld import Rietveld
-def cherry_pick(target_branch, commit):
+def cherry_pick(target_branch, commit, auth_config):
"""Attempt to upload a cherry pick CL to rietveld.
Args:
target_branch: The branch to cherry pick onto.
commit: The git hash of the commit to cherry pick.
+ auth_config: auth.AuthConfig object with authentication configuration.
"""
author = config('user.email')
@@ -48,7 +51,7 @@ def cherry_pick(target_branch, commit):
run('diff', parent, commit))),
])
- rietveld = Rietveld(config('rietveld.server'), author, None)
+ rietveld = Rietveld(config('rietveld.server'), auth_config, author)
# pylint: disable=W0212
output = rietveld._send(
'/upload',
@@ -124,21 +127,23 @@ def cherry_pick(target_branch, commit):
def main():
- parser = argparse.ArgumentParser()
- parser.add_argument(
+ parser = optparse.OptionParser(
+ usage='usage: %prog --branch <branch> <commit>')
+ parser.add_option(
'--branch',
'-b',
help='The upstream branch to cherry pick to.',
- metavar='<branch>',
- required=True,
- )
- parser.add_argument(
- 'commit',
- help='SHA to cherry pick.',
- metavar='<commit>',
- )
- args = parser.parse_args()
- cherry_pick(args.branch, args.commit)
+ metavar='<branch>')
+ auth.add_auth_options(parser)
+ options, args = parser.parse_args()
+ auth_config = auth.extract_auth_config_from_options
+
+ if not options.branch:
+ parser.error('--branch is required')
+ if len(args) != 1:
+ parser.error('Expecting single argument <commit>')
+
+ cherry_pick(options.branch, args[0], auth_config)
return 0
« no previous file with comments | « gcl.py ('k') | git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698