Page MenuHomec4science

get_repo_info.py
No OneTemporary

File Metadata

Created
Sun, Mar 7, 01:08

get_repo_info.py

#!/usr/bin/env python2
import sys
from phabricator import Phabricator
def usage():
print('''Usage:
{cmd} <RXXXX>
{cmd} <rAAAA>
Examples:
{cmd} R2
{cmd} rPHINFRA
'''.format(cmd=sys.argv[0]))
if len(sys.argv) < 2:
usage()
sys.exit(0)
arg = sys.argv[1]
if arg[0] == 'R':
constraints = {
'ids': [arg[1:]],
}
elif arg[0] == 'r':
constraints = {
'callsigns': [arg[1:]],
}
else:
print("Argument must start with r or R")
usage()
sys.exit(1)
attachments = {
'projects': 1,
'uris': 1,
}
phab = Phabricator()
repo = phab.diffusion.repository.search(
constraints=constraints,
attachments=attachments,
limit=1)
data = repo['data']
if len(data) > 0:
for d in data:
print('{rid} {name} {phid} {fields}\n'.format(
rid=d['id'],
phid=d['phid'],
name=d['fields']['name'],
fields=d['fields'],
))
else:
print("Nothing found")

Event Timeline