diff --git a/osclib/accept_command.py b/osclib/accept_command.py index 66618236..01dde5f4 100644 --- a/osclib/accept_command.py +++ b/osclib/accept_command.py @@ -7,13 +7,11 @@ from osc.core import change_request_state from osc.core import http_GET, http_PUT, http_DELETE, http_POST from osc.core import delete_package from datetime import date -from osclib.comments import CommentAPI class AcceptCommand(object): def __init__(self, api): self.api = api - self.comment = CommentAPI(self.api.apiurl) def find_new_requests(self, project): query = "match=state/@name='new'+and+(action/target/@project='{}'+and+action/@type='submit')".format(project) @@ -84,16 +82,7 @@ class AcceptCommand(object): message='Accept to %s' % self.api.project) self.create_new_links(self.api.project, req['package'], oldspecs) - # A single comment should be enough to notify everybody, since - # they are already mentioned in the comments created by - # select/unselect - pkg_list = ", ".join(packages) - cmmt = 'Project "{}" accepted.' \ - ' The following packages have been submitted to {}: {}.'.format(project, - self.api.project, - pkg_list) - self.comment.add_comment(project_name=project, comment=cmmt) - + self.api.accept_status_comment(project, packages) self.api.staging_deactivate(project) return True diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index 26b0c8c4..b05b277f 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -1397,6 +1397,14 @@ class StagingAPI(object): msg = '\n'.join(lines) comment_api.add_comment(project_name=project, comment=msg) + def accept_status_comment(self, project, packages): + # A single comment should be enough to notify everybody, since they are + # already mentioned in the comments created by select/unselect. + comment = 'Project "{}" accepted. ' \ + 'The following packages have been submitted to {}: {}.'.format( + project, self.project, ', '.join(packages)) + CommentAPI(self.apiurl).add_comment(project_name=project, comment=comment) + def mark_additional_packages(self, project, packages): """ Adds packages that the repo checker needs to download from staging prj