Chromium Code Reviews| Index: git_asdf.py |
| diff --git a/git_asdf.py b/git_asdf.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..e50209fadfd012c1af77f3513a8cff7026d8058d |
| --- /dev/null |
| +++ b/git_asdf.py |
| @@ -0,0 +1,69 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Upload a cherry pick CL to rietveld.""" |
| + |
| +import argparse |
| +import sys |
| + |
| +from git_cl import Changelist |
| +from git_common import run |
| +from third_party.upload import EncodeMultipartFormData, GitVCS |
| +from rietveld import Rietveld |
| + |
| + |
| +def cherry_pick(target_branch, commit): |
| + """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. |
| + """ |
| + author = run('config', 'user.email') |
|
agable
2014/07/15 22:47:20
use config() from git_common, rather than run('con
smut
2014/07/16 17:34:35
Done.
|
| + |
| + description = '%s\n\n(cherry picked from commit %s)\n' % ( |
|
agable
2014/07/15 22:47:20
I'd lose the parentheses -- match the format creat
smut
2014/07/16 17:34:35
This is the format I get when doing a git cherry-p
|
| + run('show', '--pretty=%B', '--quiet', commit), commit) |
|
agable
2014/07/15 22:47:20
Indent at +4.
smut
2014/07/16 17:34:35
Done.
|
| + |
| + parent = run('show', '--pretty=%P', '--quiet', commit) |
| + print 'Found parent revision:', parent |
| + |
| + class EmulateSvnAutoProps(object): |
| + def __init__(self): |
| + self.emulate_svn_auto_props = False |
| + |
| + content_type, payload = EncodeMultipartFormData([ |
| + ('base', '%s@%s' % (Changelist().GetRemoteUrl(), target_branch)), |
|
agable
2014/07/15 22:47:20
Indent +4.
agable
2014/07/15 22:47:20
Unfortunately, uploading url@branch for the issue
smut
2014/07/16 17:34:35
Done.
smut
2014/07/16 17:34:35
Ah, ok. Then I'll go with your project suggestion.
|
| + ('cc', run('config', 'rietveld.cc')), |
| + ('description', description), |
| + ('project', run('config', 'rietveld.project')), |
| + ('subject', description.splitlines()[0]), |
| + ('user', author), |
| + ], [ |
| + ('data', 'data.diff', GitVCS(EmulateSvnAutoProps()).PostProcessDiff(run('diff', parent, commit))), |
| + ]) |
| + |
| + print Rietveld(run('config', 'rietveld.server'), author, None)._send( |
| + '/upload', payload=payload, content_type=content_type) |
|
agable
2014/07/15 22:47:20
Indent +4.
smut
2014/07/16 17:34:35
Done.
|
| + |
| + |
| +def main(): |
| + parser = argparse.ArgumentParser() |
| + parser.add_argument( |
| + '--branch', |
|
agable
2014/07/15 22:47:20
Indent +4.
smut
2014/07/16 17:34:35
Done.
|
| + '-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) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |