1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

- added submitrequest log command to show the history of a given id

This commit is contained in:
Marcus Hüwe 2008-08-19 14:18:05 +00:00
parent bb11aea3fc
commit e93678d5a0
2 changed files with 27 additions and 4 deletions

View File

@ -444,6 +444,8 @@ class Osc(cmdln.Cmdln):
"list" lists open requests attached to a project or package.
"log" will show the history of the given ID
"show" will show the request itself, and generate a diff for review, if
used with the --diff option.
@ -465,6 +467,7 @@ class Osc(cmdln.Cmdln):
osc submitreq create [-m TEXT]
osc submitreq create [-m TEXT] SOURCEPRJ SOURCEPKG DESTPRJ [DESTPKG]
osc submitreq list [PRJ [PKG]]
osc submitreq log ID
osc submitreq show [-d] ID
osc submitreq accept [-m TEXT] ID
osc submitreq decline [-m TEXT] ID
@ -475,7 +478,7 @@ class Osc(cmdln.Cmdln):
args = slash_split(args)
cmds = ['create', 'list', 'show', 'decline', 'accept', 'delete', 'revoke']
cmds = ['create', 'list', 'log', 'show', 'decline', 'accept', 'delete', 'revoke']
if not args or args[0] not in cmds:
raise oscerr.WrongArgs('Unknown submitreq action. Choose one of %s.' \
% ', '.join(cmds))
@ -537,7 +540,7 @@ class Osc(cmdln.Cmdln):
if len(args) > 1:
package = args[1]
elif cmd in ['show', 'decline', 'accept', 'delete', 'revoke']:
elif cmd in ['log', 'show', 'decline', 'accept', 'delete', 'revoke']:
reqid = args[0]
@ -595,6 +598,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for result in results:
print result.list_view()
elif cmd == 'log':
for l in get_submit_request_log(conf.config['apiurl'], reqid):
print l
# show
elif cmd == 'show':
r = get_submit_request(conf.config['apiurl'], reqid)

View File

@ -1151,10 +1151,11 @@ rev: %s
class RequestState:
"""for objects to represent the "state" of a request"""
def __init__(self, name=None, who=None, when=None):
def __init__(self, name=None, who=None, when=None, comment=None):
self.name = name
self.who = who
self.when = when
self.comment = comment
class SubmitReq:
@ -1193,7 +1194,7 @@ class SubmitReq:
self.state.name, self.state.who, self.state.when \
= n.get('name'), n.get('who'), n.get('when')
try:
self.state.comment = n.find('comment').text
self.state.comment = n.find('comment').text.strip()
except:
self.state.comment = None
@ -1203,6 +1204,10 @@ class SubmitReq:
s.name = h.get('name')
s.who = h.get('who')
s.when = h.get('when')
try:
s.comment = h.find('comment').text.strip()
except:
s.comment = None
self.statehistory.append(s)
self.statehistory.reverse()
@ -1969,6 +1974,16 @@ def get_submit_request_list(apiurl, project, package, req_state=('new')):
return requests
def get_submit_request_log(apiurl, reqid):
r = get_submit_request(conf.config['apiurl'], reqid)
data = []
frmt = '-' * 76 + '\n%s | %s | %s\n\n%s'
for state in [ r.state ] + r.statehistory:
s = frmt % (state.name, state.who, state.when, str(state.comment))
data.append(s)
return data
def get_user_meta(apiurl, user):
u = makeurl(apiurl, ['person', quote_plus(user)])
try: