mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-02 09:46:16 +01:00
Added -V, --version to do_search.
This shows all the hard to retrieve, but 'essential' details about a package: version, revision, srcmd5 If there is a better way some day, than digging through _history, please improve core.py:get_source_rev() It is a new option, only because it is so slow; the version number should rather be in default output.
This commit is contained in:
parent
f30297d2d3
commit
ce3ee5e614
@ -4987,6 +4987,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
help='match only when given attribute exists in meta data')
|
||||
@cmdln.option('-v', '--verbose', action='store_true',
|
||||
help='show more information')
|
||||
@cmdln.option('-V', '--version', action='store_true',
|
||||
help='show package version, revision, and srcmd5. CAUTION: This is slow and unreliable')
|
||||
@cmdln.option('-i', '--involved', action='store_true',
|
||||
help='show projects/packages where given person (or myself) is involved as bugowner or maintainer')
|
||||
@cmdln.option('-b', '--bugowner', action='store_true',
|
||||
@ -5125,11 +5127,25 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
result.append(project)
|
||||
if not package is None:
|
||||
result.append(package)
|
||||
|
||||
if opts.version:
|
||||
sr = get_source_rev(apiurl,project,package)
|
||||
v = sr.get('version')
|
||||
r = sr.get('rev')
|
||||
s = sr.get('srcmd5')
|
||||
if not v or v == 'unknown': v = '-'
|
||||
if not r: r = '-'
|
||||
if not s: s = '-'
|
||||
result.append(v)
|
||||
result.append(r)
|
||||
result.append(s)
|
||||
|
||||
if opts.verbose:
|
||||
title = node.findtext('title').strip()
|
||||
if len(title) > 60:
|
||||
title = title[:61] + '...'
|
||||
result.append(title)
|
||||
|
||||
if opts.repos_baseurl:
|
||||
# FIXME: no hardcoded URL of instance
|
||||
result.append('http://download.opensuse.org/repositories/%s/' % project.replace(':', ':/'))
|
||||
@ -5153,6 +5169,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
headline = [ '# Project', '# Package' ]
|
||||
else:
|
||||
headline = [ '# Project' ]
|
||||
if opts.version:
|
||||
headline.append('# Ver')
|
||||
headline.append('Rev')
|
||||
headline.append('Srcmd5')
|
||||
if opts.verbose:
|
||||
headline.append('# Title')
|
||||
if opts.repos_baseurl:
|
||||
|
27
osc/core.py
27
osc/core.py
@ -4651,6 +4651,33 @@ def get_buildconfig(apiurl, prj, repository):
|
||||
f = http_GET(u)
|
||||
return f.read()
|
||||
|
||||
|
||||
def get_source_rev(apiurl, project, package, revision=None):
|
||||
# API supports ?deleted=1&meta=1&rev=4
|
||||
# but not rev=current,rev=latest,rev=top, or anything like this.
|
||||
# CAUTION: We have to loop through all rev and find the highest one, if none given.
|
||||
|
||||
if revision:
|
||||
url = makeurl(apiurl, ['source', project, package, '_history'], {'rev':revision})
|
||||
else:
|
||||
url = makeurl(apiurl, ['source', project, package, '_history'])
|
||||
f = http_GET(url)
|
||||
xml = ET.parse(f)
|
||||
ent = None
|
||||
for new in xml.findall('revision'):
|
||||
# remember the newest one.
|
||||
if not ent:
|
||||
ent = new
|
||||
elif ent.find('time').text < new.find('time').text:
|
||||
ent = new
|
||||
if not ent:
|
||||
return { 'version': None, 'error':'empty revisionlist: no such package?' }
|
||||
e = {}
|
||||
for k in ent.keys():
|
||||
e[k] = ent.get(k)
|
||||
for k in list(ent):
|
||||
e[k.tag] = k.text
|
||||
return e
|
||||
|
||||
def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text'):
|
||||
import time
|
||||
|
Loading…
Reference in New Issue
Block a user