Allow specifying remote branch at listing changes
Signed-off-by: You-Sheng Yang (vicamo) <vicamo@gmail.com> Change-Id: I9267598fcf2eb9316023c453d29bb1ffe4f94404
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
.Op Ar branch
|
.Op Ar branch
|
||||||
.Nm
|
.Nm
|
||||||
.Fl l
|
.Fl l
|
||||||
|
.Op Ar branch
|
||||||
.Nm
|
.Nm
|
||||||
.Fl \-version
|
.Fl \-version
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ def parse_gerrit_ssh_params_from_git_url(git_url):
|
|||||||
return (hostname, username, port, project_name)
|
return (hostname, username, port, project_name)
|
||||||
|
|
||||||
|
|
||||||
def query_reviews(remote_url, project=None, change=None,
|
def query_reviews(remote_url, project=None, branch=None, change=None,
|
||||||
current_patch_set=True, exception=CommandFailed,
|
current_patch_set=True, exception=CommandFailed,
|
||||||
parse_exc=Exception):
|
parse_exc=Exception):
|
||||||
if remote_url.startswith('http://') or remote_url.startswith('https://'):
|
if remote_url.startswith('http://') or remote_url.startswith('https://'):
|
||||||
@@ -632,13 +632,14 @@ def query_reviews(remote_url, project=None, change=None,
|
|||||||
query = query_reviews_over_ssh
|
query = query_reviews_over_ssh
|
||||||
return query(remote_url,
|
return query(remote_url,
|
||||||
project=project,
|
project=project,
|
||||||
|
branch=branch,
|
||||||
change=change,
|
change=change,
|
||||||
current_patch_set=current_patch_set,
|
current_patch_set=current_patch_set,
|
||||||
exception=exception,
|
exception=exception,
|
||||||
parse_exc=parse_exc)
|
parse_exc=parse_exc)
|
||||||
|
|
||||||
|
|
||||||
def query_reviews_over_http(remote_url, project=None, change=None,
|
def query_reviews_over_http(remote_url, project=None, branch=None, change=None,
|
||||||
current_patch_set=True, exception=CommandFailed,
|
current_patch_set=True, exception=CommandFailed,
|
||||||
parse_exc=Exception):
|
parse_exc=Exception):
|
||||||
if project:
|
if project:
|
||||||
@@ -666,7 +667,10 @@ def query_reviews_over_http(remote_url, project=None, change=None,
|
|||||||
else:
|
else:
|
||||||
project_name = re.sub(r"^/|(\.git$)", "",
|
project_name = re.sub(r"^/|(\.git$)", "",
|
||||||
urlparse(remote_url).path)
|
urlparse(remote_url).path)
|
||||||
params = urlencode({'q': 'project:%s status:open' % project_name})
|
query = 'project:%s status:open' % project_name
|
||||||
|
if branch:
|
||||||
|
query += ' branch:%s' % branch
|
||||||
|
params = urlencode({'q': query})
|
||||||
url += '?' + params
|
url += '?' + params
|
||||||
|
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
@@ -696,7 +700,7 @@ def query_reviews_over_http(remote_url, project=None, change=None,
|
|||||||
return reviews
|
return reviews
|
||||||
|
|
||||||
|
|
||||||
def query_reviews_over_ssh(remote_url, project=None, change=None,
|
def query_reviews_over_ssh(remote_url, project=None, branch=None, change=None,
|
||||||
current_patch_set=True, exception=CommandFailed,
|
current_patch_set=True, exception=CommandFailed,
|
||||||
parse_exc=Exception):
|
parse_exc=Exception):
|
||||||
(hostname, username, port, project_name) = \
|
(hostname, username, port, project_name) = \
|
||||||
@@ -709,6 +713,8 @@ def query_reviews_over_ssh(remote_url, project=None, change=None,
|
|||||||
query = "--patch-sets change:%s" % change
|
query = "--patch-sets change:%s" % change
|
||||||
else:
|
else:
|
||||||
query = "project:%s status:open" % project_name
|
query = "project:%s status:open" % project_name
|
||||||
|
if branch:
|
||||||
|
query += ' branch:%s' % branch
|
||||||
|
|
||||||
port_data = "p%s" % port if port is not None else ""
|
port_data = "p%s" % port if port is not None else ""
|
||||||
if username is None:
|
if username is None:
|
||||||
@@ -1150,12 +1156,13 @@ class ReviewsPrinter(object):
|
|||||||
print("Found %d items for review" % total_reviews)
|
print("Found %d items for review" % total_reviews)
|
||||||
|
|
||||||
|
|
||||||
def list_reviews(remote, project, with_topic=False):
|
def list_reviews(remote, project, branch=None, with_topic=False):
|
||||||
remote_url = get_remote_url(remote)
|
remote_url = get_remote_url(remote)
|
||||||
|
|
||||||
reviews = []
|
reviews = []
|
||||||
for r in query_reviews(remote_url,
|
for r in query_reviews(remote_url,
|
||||||
project=project,
|
project=project,
|
||||||
|
branch=branch,
|
||||||
exception=CannotQueryOpenChangesets,
|
exception=CannotQueryOpenChangesets,
|
||||||
parse_exc=CannotParseOpenChangesets):
|
parse_exc=CannotParseOpenChangesets):
|
||||||
reviews.append(Review(r))
|
reviews.append(Review(r))
|
||||||
@@ -1752,7 +1759,9 @@ additional information:
|
|||||||
return
|
return
|
||||||
elif options.list:
|
elif options.list:
|
||||||
with_topic = options.list > 1
|
with_topic = options.list > 1
|
||||||
list_reviews(remote, config['project'], with_topic=with_topic)
|
list_reviews(remote, config['project'],
|
||||||
|
branch if options.branch or options.track else None,
|
||||||
|
with_topic=with_topic)
|
||||||
return
|
return
|
||||||
|
|
||||||
if options.custom_script:
|
if options.custom_script:
|
||||||
|
|||||||
Reference in New Issue
Block a user