summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-09 12:51:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-09 12:51:27 +0000
commit82a1a0f2b42e6088ae1b5b7531dc735b0a071c46 (patch)
tree2650287ca4347646bdb1bf62020775712144a0f3
parent21592eede99a6c0c446aff0f5e8dd7380a2adca2 (diff)
parent0b07f76c2dbbeb765aa349f0be44c5fd8f1855dc (diff)
downloaddevelopment-82a1a0f2b42e6088ae1b5b7531dc735b0a071c46.tar.gz
Merge "gerrit: Add parsing friendly output format" into main
-rwxr-xr-xtools/repo_pull/gerrit.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/repo_pull/gerrit.py b/tools/repo_pull/gerrit.py
index c93461d25..601c3ff5c 100755
--- a/tools/repo_pull/gerrit.py
+++ b/tools/repo_pull/gerrit.py
@@ -608,7 +608,7 @@ def _parse_args():
parser = argparse.ArgumentParser()
add_common_parse_args(parser)
parser.add_argument('--format', default='json',
- choices=['json', 'oneline'],
+ choices=['json', 'oneline', 'porcelain'],
help='Print format')
return parser.parse_args()
@@ -635,16 +635,22 @@ def main():
if args.format == 'json':
json.dump(change_lists, sys.stdout, indent=4, separators=(', ', ': '))
print() # Print the end-of-line
- elif args.format == 'oneline':
+ else:
+ if args.format == 'oneline':
+ format_str = ('{i:<8} {number:<16} {status:<20} '
+ '{change_id:<60} {project:<120} '
+ '{subject}')
+ else:
+ format_str = ('{i}\t{number}\t{status}\t'
+ '{change_id}\t{project}\t{subject}')
+
for i, change in enumerate(change_lists):
- print('{i:<8} {number:<16} {status:<20} ' \
- '{change_id:<60} {project:<120} ' \
- '{subject}'.format(i=i,
- project=change['project'],
- change_id=change['change_id'],
- status=change['status'],
- number=change['_number'],
- subject=change['subject']))
+ print(format_str.format(i=i,
+ project=change['project'],
+ change_id=change['change_id'],
+ status=change['status'],
+ number=change['_number'],
+ subject=change['subject']))
if __name__ == '__main__':