1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 09:16:16 +02:00

Merge pull request #747 from adrianschroeter/request_diffing

support request diffing relative to a former request
This commit is contained in:
Daniel Mach 2022-03-16 14:20:20 +01:00 committed by GitHub
commit cb4b2389a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -2150,6 +2150,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('-d', '--diff', action='store_true',
help='generate a diff')
@cmdln.option('-S', '--superseded-request', metavar='SUPERSEDED_REQUEST',
help='Create the diff relative to a given former request')
@cmdln.option('-u', '--unified', action='store_true',
help='output the diff in the unified diff format')
@cmdln.option('--no-devel', action='store_true',
@ -2575,8 +2577,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
diff = b''
try:
# works since OBS 2.1
diff = request_diff(apiurl, reqid)
diff = request_diff(apiurl, reqid, opts.superseded_request)
except HTTPError as e:
if e.code == 404:
# Any referenced object does not exist, eg. the superseded request
root = ET.fromstring(e.read())
summary = root.find('summary')
print(summary.text, file=sys.stderr)
raise oscerr.WrongOptions("Object does not exist")
# for OBS 2.0 and before
sr_actions = r.get_actions('submit')
if not r.get_actions('submit') and not r.get_actions('maintenance_incident') and not r.get_actions('maintenance_release'):

View File

@ -4952,8 +4952,11 @@ def server_diff_noex(apiurl,
return rdiff
def request_diff(apiurl, reqid):
u = makeurl(apiurl, ['request', reqid], query={'cmd': 'diff'} )
def request_diff(apiurl, reqid, superseded_reqid=None):
query = {'cmd': 'diff'}
if superseded_reqid:
query['diff_to_superseded'] = superseded_reqid
u = makeurl(apiurl, ['request', reqid], query)
f = http_POST(u)
return f.read()