Skip to content
Snippets Groups Projects
Commit 0bf69658 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Only add to maintainers if not already maintainer

parent 496f274c
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -64,26 +64,37 @@ def do_mpcdf_push(self, subcmd, opts, *args): ...@@ -64,26 +64,37 @@ def do_mpcdf_push(self, subcmd, opts, *args):
project_attributes = ["MPCDF:compiler_modules", "MPCDF:cuda_modules", "MPCDF:mpi_modules"] project_attributes = ["MPCDF:compiler_modules", "MPCDF:cuda_modules", "MPCDF:mpi_modules"]
package_attributes = ["MPCDF:enable_repositories"] + project_attributes package_attributes = ["MPCDF:enable_repositories"] + project_attributes
try:
root = ElementTree.fromstringlist(osc.core.show_package_meta(api_url, to_project, package))
existing_maintainers = {e.get("userid") for e in root.findall("./person[@role='maintainer']")}
except osc.core.HTTPError as e:
if e.code == 404:
existing_maintainers = set()
else:
raise e
req_id = osc.core.create_submit_request(api_url, from_project, package, dst_project=to_project, req_id = osc.core.create_submit_request(api_url, from_project, package, dst_project=to_project,
message="Update {0} from {1}".format(package, from_project) if not opts.message else opts.message) message="Update {0} from {1}".format(package, from_project) if not opts.message else opts.message)
print("Submitted package {0} to {1} in request {2}".format(package, to_project, req_id)) print("Submitted package {0} to {1} in request {2}".format(package, to_project, req_id))
if not opts.batch: if not opts.batch:
print(" PLEASE review the request by 'osc request show {0} --diff', or in the web interface".format(req_id)) print("\nPLEASE review the request by 'osc request show {0} --diff', or in the web interface\n".format(req_id))
print(" Do you want to accept the request right away? [y/N] ", end="") print("Do you want to accept the request right away? [y/N] ", end="")
response = input().lower() response = input().lower()
if response == "y": if response == "y":
result = osc.core.change_request_state(api_url, req_id, 'accepted', "Accepted on the command line via 'osc mpcdf_push'") result = osc.core.change_request_state(api_url, req_id, 'accepted', "Accepted on the command line via 'osc mpcdf_push'")
print(" Accepting request {0}:".format(req_id), result) print(" Accepting request {0}:".format(req_id), result)
print("Adding you to the list of maintainers for this package (for informational purposes only)")
user = osc.conf.get_apiurl_usr(api_url) user = osc.conf.get_apiurl_usr(api_url)
r = osc.core.Request() if user not in existing_maintainers:
r.add_action("add_role", tgt_project=to_project, tgt_package=package, person_name=user, person_role="maintainer") print("Adding you to the list of maintainers for this package")
r.description = "Add user {0} as maintainer due to 'osc mpcdf_push'".format(user) r = osc.core.Request()
r.create(api_url) r.add_action("add_role", tgt_project=to_project, tgt_package=package, person_name=user, person_role="maintainer")
if response == "y": r.description = "Add user {0} as maintainer due to 'osc mpcdf_push'".format(user)
result = osc.core.change_request_state(api_url, r.reqid, 'accepted', "Accepted on the command line via 'osc mpcdf_push'") r.create(api_url)
print(" Accepting request {0}:".format(r.reqid), result) if response == "y":
result = osc.core.change_request_state(api_url, r.reqid, 'accepted', "Accepted on the command line via 'osc mpcdf_push'")
print(" Accepting request {0}:".format(r.reqid), result)
print()
# Give the system some time, sadly there is no transactional guarantee # Give the system some time, sadly there is no transactional guarantee
time.sleep(2) time.sleep(2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment