1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-30 19:56:14 +01:00

Merge branch 'osc_meta_blame' of https://github.com/lethliel/osc

Add --blame option to the "meta" command (it only works for the
"prj", "pkg", and "prjconf" kinds). Note: the functions
show_project_meta and show_package_meta can return xml and non-xml
(depending on the value of the "blame" parameter).
This commit is contained in:
Marcus Huewe 2017-03-22 12:42:13 +01:00
commit bbd5a92226
2 changed files with 24 additions and 10 deletions

View File

@ -738,6 +738,8 @@ class Osc(cmdln.Cmdln):
help='include defined attribute defaults') help='include defined attribute defaults')
@cmdln.option('--attribute-project', action='store_true', @cmdln.option('--attribute-project', action='store_true',
help='include project values, if missing in packages ') help='include project values, if missing in packages ')
@cmdln.option('--blame', action='store_true',
help='show author and time of each line')
@cmdln.option('-f', '--force', action='store_true', @cmdln.option('-f', '--force', action='store_true',
help='force the save operation, allows one to ignores some errors like depending repositories. For prj meta only.') help='force the save operation, allows one to ignores some errors like depending repositories. For prj meta only.')
@cmdln.option('-F', '--file', metavar='FILE', @cmdln.option('-F', '--file', metavar='FILE',
@ -889,14 +891,14 @@ class Osc(cmdln.Cmdln):
# show # show
if not opts.edit and not opts.file and not opts.delete and not opts.create and not opts.set: if not opts.edit and not opts.file and not opts.delete and not opts.create and not opts.set:
if cmd == 'prj': if cmd == 'prj':
sys.stdout.write(''.join(show_project_meta(apiurl, project, opts.revision))) sys.stdout.write(''.join(show_project_meta(apiurl, project, rev=opts.revision, blame=opts.blame)))
elif cmd == 'pkg': elif cmd == 'pkg':
sys.stdout.write(''.join(show_package_meta(apiurl, project, package))) sys.stdout.write(''.join(show_package_meta(apiurl, project, package, blame=opts.blame)))
elif cmd == 'attribute': elif cmd == 'attribute':
sys.stdout.write(''.join(show_attribute_meta(apiurl, project, package, subpackage, sys.stdout.write(''.join(show_attribute_meta(apiurl, project, package, subpackage,
opts.attribute, opts.attribute_defaults, opts.attribute_project))) opts.attribute, opts.attribute_defaults, opts.attribute_project)))
elif cmd == 'prjconf': elif cmd == 'prjconf':
sys.stdout.write(''.join(show_project_conf(apiurl, project, opts.revision))) sys.stdout.write(''.join(show_project_conf(apiurl, project, rev=opts.revision, blame=opts.blame)))
elif cmd == 'user': elif cmd == 'user':
r = get_user_meta(apiurl, user) r = get_user_meta(apiurl, user)
if r: if r:

View File

@ -3396,9 +3396,11 @@ def meta_get_project_list(apiurl, deleted=None):
return sorted([ node.get('name') for node in root if node.get('name')]) return sorted([ node.get('name') for node in root if node.get('name')])
def show_project_meta(apiurl, prj, rev=None): def show_project_meta(apiurl, prj, rev=None, blame=None):
if rev:
query = {} query = {}
if blame:
query['view'] = "blame"
if rev:
query['rev'] = rev query['rev'] = rev
url = makeurl(apiurl, ['source', prj, '_project', '_meta'], query) url = makeurl(apiurl, ['source', prj, '_project', '_meta'], query)
try: try:
@ -3412,17 +3414,24 @@ def show_project_meta(apiurl, prj, rev=None):
error_help = 'option -r|--revision is not supported by this OBS version' error_help = 'option -r|--revision is not supported by this OBS version'
e.osc_msg = 'BuildService API error: %s' % error_help e.osc_msg = 'BuildService API error: %s' % error_help
raise raise
else:
if blame:
url = makeurl(apiurl, ['source', prj, '_project', '_meta'], query)
else: else:
url = makeurl(apiurl, ['source', prj, '_meta']) url = makeurl(apiurl, ['source', prj, '_meta'])
f = http_GET(url) f = http_GET(url)
return f.readlines() return f.readlines()
def show_project_conf(apiurl, prj, rev=None): def show_project_conf(apiurl, prj, rev=None, blame=None):
query = {} query = {}
url = None
if rev: if rev:
query['rev'] = rev query['rev'] = rev
if blame:
url = makeurl(apiurl, ['source', prj, '_config'], query) query['view'] = "blame"
url = makeurl(apiurl, ['source', prj, '_project', '_config'], query=query)
else:
url = makeurl(apiurl, ['source', prj, '_config'], query=query)
f = http_GET(url) f = http_GET(url)
return f.readlines() return f.readlines()
@ -3437,10 +3446,13 @@ def show_package_trigger_reason(apiurl, prj, pac, repo, arch):
raise raise
def show_package_meta(apiurl, prj, pac, meta=False): def show_package_meta(apiurl, prj, pac, meta=False, blame=None):
query = {} query = {}
if meta: if meta:
query['meta'] = 1 query['meta'] = 1
if blame:
query['view'] = "blame"
query['meta'] = 1
# The fake packages _project has no _meta file # The fake packages _project has no _meta file
if pac.startswith('_project'): if pac.startswith('_project'):