From 3b51a7e044594bffefc4b4dd2a2319828df623a5 Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Fri, 1 Nov 2019 14:31:41 -0500 Subject: [PATCH] osclib/origin: origin_update() generate change_devel requests. As a follow-up to new packages accepted from a specific devel generate a change_devel request automatically. Such requests should be approved automatically since they are a workaround to not being able to set devel during source submission. --- origin-manager.py | 8 ++++++++ osclib/origin.py | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/origin-manager.py b/origin-manager.py index af6a9ed1..f3df592a 100755 --- a/origin-manager.py +++ b/origin-manager.py @@ -50,6 +50,14 @@ class OriginManager(ReviewBot.ReviewBot): if key in ('fallback', 'maintainer'): reviews[key] = comment + if result.accept: + config = config_load(self.apiurl, action.tgt_project) + if request.creator == config['review-user']: + # Remove all reviews since the request was generated via + # origin_update() which indicates it was approved already. Acts + # as workaround for to lack of set devel on a submit request. + reviews = {} + if len(reviews) != len(result.reviews): result = PolicyResult(result.wait, result.accept, reviews, result.comments) diff --git a/osclib/origin.py b/osclib/origin.py index dda1f1a8..0ba49b5d 100644 --- a/osclib/origin.py +++ b/osclib/origin.py @@ -15,6 +15,7 @@ from osclib.core import project_remote_apiurl from osclib.core import request_action_key from osclib.core import request_action_list from osclib.core import request_action_list_source +from osclib.core import request_create_change_devel from osclib.core import request_create_delete from osclib.core import request_create_submit from osclib.core import request_remote_identifier @@ -603,6 +604,32 @@ def origin_history(apiurl, target_project, package, user): def origin_update(apiurl, target_project, package): origin_info = origin_find(apiurl, target_project, package) if not origin_info: + # Cases for a lack of origin: + # - initial package submission from devel (lacking devel meta on package) + # - initial package submission overriden to allow from no origin + # - origin project/package deleted + # + # Ideally, the second case should never be used and instead the first + # case should be opted for instead. + + # Check for accepted source submission with devel annotation and create + # change_devel request as automatic follow-up to approval. + config = config_load(apiurl, target_project) + request_actions = request_action_list_source(apiurl, target_project, package, states=['accepted']) + for request, action in sorted(request_actions, key=lambda i: i[0].reqid, reverse=True): + annotation = origin_annotation_load(request, action, config['review-user']) + if not annotation: + continue + + origin = annotation.get('origin') + if origin_workaround_check(origin): + continue + + if origin not in config_origin_list(config, apiurl, target_project): + message = f'Set devel project based on initial submission in request#{request.reqid}.' + return request_create_change_devel(apiurl, origin, package, target_project, message=message) + + # One of the second two cases. origin, version = origin_potential(apiurl, target_project, package) if origin is None: # Package is not found in any origin so request deletion.