mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-25 03:32:15 +01:00
simplify osc sr code in submitting prj
Most of the stuff is now done in the API. For just submitting all in one request the following is sufficient: <action type="submit"> <source project="%s" /> %s </action> If a target project is given it looks like this: <action type="submit"> <source project="%s" /> <target project="%s"> %s </action> We don't need package name or source package and targets anymore. This is all handled by the API now. For the --seperate-requests case the check for the entries in the linkinfo is not working on most cases. So we handle this in the do_submitrequest and skip the package if X-Opensuse-Errorcode is missing_action which means basically nothing to do for this package redesign target_project handling
This commit is contained in:
parent
181bfe8c75
commit
3da7b9b3d8
@ -1236,24 +1236,17 @@ class Osc(cmdln.Cmdln):
|
|||||||
project = store_read_project(os.curdir)
|
project = store_read_project(os.curdir)
|
||||||
|
|
||||||
sr_ids = []
|
sr_ids = []
|
||||||
# for single request
|
|
||||||
actionxml = ""
|
|
||||||
options_block = "<options>"
|
|
||||||
if src_update:
|
|
||||||
options_block += """<sourceupdate>%s</sourceupdate>""" % (src_update)
|
|
||||||
if opts.update_link:
|
|
||||||
options_block + """<updatelink>true</updatelink></options> """
|
|
||||||
options_block += "</options>"
|
|
||||||
|
|
||||||
# loop via all packages for checking their state
|
target_project = None
|
||||||
|
if len(args) == 1:
|
||||||
|
target_project = args[0]
|
||||||
|
if opts.separate_requests or opts.seperate_requests:
|
||||||
for p in meta_get_packagelist(apiurl, project):
|
for p in meta_get_packagelist(apiurl, project):
|
||||||
# get _link info from server, that knows about the local state ...
|
# get _link info from server, that knows about the local state ...
|
||||||
u = makeurl(apiurl, ['source', project, p])
|
u = makeurl(apiurl, ['source', project, p])
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
target_project = None
|
_check_service(root)
|
||||||
if len(args) == 1:
|
|
||||||
target_project = args[0]
|
|
||||||
linkinfo = root.find('linkinfo')
|
linkinfo = root.find('linkinfo')
|
||||||
if linkinfo == None:
|
if linkinfo == None:
|
||||||
if len(args) < 1:
|
if len(args) < 1:
|
||||||
@ -1264,36 +1257,34 @@ class Osc(cmdln.Cmdln):
|
|||||||
print("Package ", p, " is a broken source link.")
|
print("Package ", p, " is a broken source link.")
|
||||||
sys.exit("Please fix this first")
|
sys.exit("Please fix this first")
|
||||||
t = linkinfo.get('project')
|
t = linkinfo.get('project')
|
||||||
if t:
|
if t is None:
|
||||||
if target_project == None:
|
|
||||||
target_project = t
|
|
||||||
if len(root.findall('entry')) > 1: # This is not really correct, but should work mostly
|
|
||||||
# Real fix is to ask the api if sources are modificated
|
|
||||||
# but there is no such call yet.
|
|
||||||
print("Submitting package ", p)
|
|
||||||
else:
|
|
||||||
print(" Skipping not modified package ", p)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
print("Skipping package ", p, " since it is a source link pointing inside the project.")
|
print("Skipping package ", p, " since it is a source link pointing inside the project.")
|
||||||
continue
|
continue
|
||||||
|
print("Submitting package ", p)
|
||||||
# check for failed source service
|
try:
|
||||||
_check_service(root)
|
result = create_submit_request(apiurl, project, p, target_project, src_update=src_update)
|
||||||
|
except HTTPError as e:
|
||||||
# submitting this package
|
if e.hdrs.get('X-Opensuse-Errorcode') == 'missing_action':
|
||||||
if opts.separate_requests or opts.seperate_requests:
|
print("Package ", p, " no changes. Skipping...")
|
||||||
# create a single request
|
continue
|
||||||
result = create_submit_request(apiurl, project, p, src_update=src_update)
|
raise
|
||||||
if not result:
|
if not result:
|
||||||
sys.exit("submit request creation failed")
|
sys.exit("submit request creation failed")
|
||||||
sr_ids.append(result)
|
sr_ids.append(result)
|
||||||
else:
|
else:
|
||||||
s = """<action type="submit"> <source project="%s" package="%s" /> <target project="%s" package="%s" /> %s </action>""" % \
|
actionxml = ""
|
||||||
(project, p, target_project, p, options_block)
|
options_block = "<options>"
|
||||||
|
if src_update:
|
||||||
|
options_block += """<sourceupdate>%s</sourceupdate>""" % (src_update)
|
||||||
|
if opts.update_link:
|
||||||
|
options_block + """<updatelink>true</updatelink></options> """
|
||||||
|
options_block += "</options>"
|
||||||
|
target_prj_block = ""
|
||||||
|
if target_project is not None:
|
||||||
|
target_prj_block = """<target project="%s"/>""" % target_project
|
||||||
|
s = """<action type="submit"> <source project="%s" /> %s %s </action>""" % \
|
||||||
|
(project, target_prj_block, options_block)
|
||||||
actionxml += s
|
actionxml += s
|
||||||
|
|
||||||
if actionxml != "":
|
|
||||||
xml = """<request> %s <state name="new"/> <description>%s</description> </request> """ % \
|
xml = """<request> %s <state name="new"/> <description>%s</description> </request> """ % \
|
||||||
(actionxml, cgi.escape(opts.message or ""))
|
(actionxml, cgi.escape(opts.message or ""))
|
||||||
u = makeurl(apiurl, ['request'], query='cmd=create&addrevision=1')
|
u = makeurl(apiurl, ['request'], query='cmd=create&addrevision=1')
|
||||||
@ -1302,7 +1293,7 @@ class Osc(cmdln.Cmdln):
|
|||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
sr_ids.append(root.get('id'))
|
sr_ids.append(root.get('id'))
|
||||||
|
|
||||||
print("Request created: ", end=' ')
|
print("Request(s) created: ", end=' ')
|
||||||
for i in sr_ids:
|
for i in sr_ids:
|
||||||
print(i, end=' ')
|
print(i, end=' ')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user