Add options for git-repo to support private and wip changes

This change adds options for git-repo tool to support private
changes and work-in-progress changes.

Change-Id: I343491f5949f06f1580d53f9cc0dee2dca09130f
This commit is contained in:
Changcheng Xiao 2017-08-02 16:55:03 +02:00
parent ffc1401327
commit 87984c6db4
2 changed files with 23 additions and 1 deletions

View File

@ -176,11 +176,15 @@ class ReviewableBranch(object):
def UploadForReview(self, people, def UploadForReview(self, people,
auto_topic=False, auto_topic=False,
draft=False, draft=False,
private=False,
wip=False,
dest_branch=None): dest_branch=None):
self.project.UploadForReview(self.name, self.project.UploadForReview(self.name,
people, people,
auto_topic=auto_topic, auto_topic=auto_topic,
draft=draft, draft=draft,
private=private,
wip=wip,
dest_branch=dest_branch) dest_branch=dest_branch)
def GetPublishedRefs(self): def GetPublishedRefs(self):
@ -1107,6 +1111,8 @@ class Project(object):
people=([], []), people=([], []),
auto_topic=False, auto_topic=False,
draft=False, draft=False,
private=False,
wip=False,
dest_branch=None): dest_branch=None):
"""Uploads the named branch for code review. """Uploads the named branch for code review.
""" """
@ -1158,9 +1164,14 @@ class Project(object):
dest_branch) dest_branch)
if auto_topic: if auto_topic:
ref_spec = ref_spec + '/' + branch.name ref_spec = ref_spec + '/' + branch.name
if not url.startswith('ssh://'): if not url.startswith('ssh://'):
rp = ['r=%s' % p for p in people[0]] + \ rp = ['r=%s' % p for p in people[0]] + \
['cc=%s' % p for p in people[1]] ['cc=%s' % p for p in people[1]]
if private:
rp = rp + ['private']
if wip:
rp = rp + ['wip']
if rp: if rp:
ref_spec = ref_spec + '%' + ','.join(rp) ref_spec = ref_spec + '%' + ','.join(rp)
cmd.append(ref_spec) cmd.append(ref_spec)

View File

@ -154,6 +154,12 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
p.add_option('-d', '--draft', p.add_option('-d', '--draft',
action='store_true', dest='draft', default=False, action='store_true', dest='draft', default=False,
help='If specified, upload as a draft.') help='If specified, upload as a draft.')
p.add_option('-p', '--private',
action='store_true', dest='private', default=False,
help='If specified, upload as a private change.')
p.add_option('-w', '--wip',
action='store_true', dest='wip', default=False,
help='If specified, upload as a work-in-progress change.')
p.add_option('-D', '--destination', '--dest', p.add_option('-D', '--destination', '--dest',
type='string', action='store', dest='dest_branch', type='string', action='store', dest='dest_branch',
metavar='BRANCH', metavar='BRANCH',
@ -378,7 +384,12 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
branch.uploaded = False branch.uploaded = False
continue continue
branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft, dest_branch=destination) branch.UploadForReview(people,
auto_topic=opt.auto_topic,
draft=opt.draft,
private=opt.private,
wip=opt.wip,
dest_branch=destination)
branch.uploaded = True branch.uploaded = True
except UploadError as e: except UploadError as e:
branch.error = e branch.error = e