repo-patch: Download patch files from Gerrit
This commit adds a utility to download multiple patch files from Gerrit by a change list query. Test: repo_patch.py -g [gerrit] [query] Change-Id: I3685c48d2ea4e5a9fa1915c4e31bc6ebb2d4ed97
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
@@ -158,6 +159,19 @@ def set_review(url_opener, gerrit_url, change_id, labels, message):
|
||||
response_file.close()
|
||||
|
||||
|
||||
def get_patch(url_opener, gerrit_url, change_id, revision_id='current'):
|
||||
"""Download the patch file."""
|
||||
|
||||
url = '{}/a/changes/{}/revisions/{}/patch'.format(
|
||||
gerrit_url, change_id, revision_id)
|
||||
|
||||
response_file = url_opener.open(url)
|
||||
try:
|
||||
return base64.b64decode(response_file.read())
|
||||
finally:
|
||||
response_file.close()
|
||||
|
||||
|
||||
def _parse_args():
|
||||
"""Parse command line options."""
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
Reference in New Issue
Block a user