@@ -42,6 +42,7 @@ def __init__(
4242 job_config = job_config ,
4343 event = event ,
4444 )
45+ self .action = event ["action" ]
4546 self .mr_identifier = event ["identifier" ]
4647 self .mr_title = event ["title" ]
4748 self .mr_description = event ["description" ]
@@ -116,11 +117,11 @@ def run(self) -> TaskResults:
116117 "Not creating a dist-git MR from "
117118 f"{ self .target_repo } :{ self .target_repo_branch } "
118119 )
119- return TaskResults (success = True , details = {} )
120+ return TaskResults (success = True )
120121
121122 if not self .package_config :
122123 logger .debug ("No package config found." )
123- return TaskResults (success = True , details = {} )
124+ return TaskResults (success = True )
124125
125126 if (
126127 self .target_repo_branch
@@ -132,16 +133,23 @@ def run(self) -> TaskResults:
132133 return TaskResults (success = True )
133134
134135 if self .dist_git_pr_model :
135- # The source-git PR was probably closed and then reopened
136136 logger .info (
137137 f"{ self .source_git_pr_model } already has corresponding { self .dist_git_pr_model } "
138138 )
139139 if self .dist_git_pr :
140- # TODO: reopen the corresponding dist-git PR as well if it's already closed
141- # https://github.com/packit/ogr/pull/714
142- comment = f"[Source-git MR]({ self .mr_url } ) has been reopened."
143- self .dist_git_pr .comment (comment )
144- return TaskResults (success = True , details = {})
140+ if self .action == "close" :
141+ msg = f"[Source-git MR]({ self .mr_url } ) has been closed."
142+ self .dist_git_pr .close ()
143+ elif self .action == "open" :
144+ msg = f"[Source-git MR]({ self .mr_url } ) has been reopened."
145+ # https://github.com/packit/ogr/pull/714
146+ # self.dist_git_pr.reopen()
147+ else :
148+ logger .error (f"Unknown action { self .action } " )
149+ TaskResults (success = False )
150+ logger .info (msg )
151+ self .dist_git_pr .comment (msg )
152+ return TaskResults (success = True )
145153
146154 dg_mr_info = f"""###### Info for package maintainer
147155This MR has been automatically created from
@@ -227,12 +235,12 @@ def run(self) -> TaskResults:
227235 """
228236 if not (dist_git_pr_model := self .dist_git_pr_model ()):
229237 logger .debug ("No dist-git PR model." )
230- return TaskResults (success = True , details = {} )
238+ return TaskResults (success = True )
231239 if not (
232240 sg_dg := SourceGitPRDistGitPRModel .get_by_dist_git_id (dist_git_pr_model .id )
233241 ):
234242 logger .debug (f"Source-git PR for { dist_git_pr_model } not found." )
235- return TaskResults (success = True , details = {} )
243+ return TaskResults (success = True )
236244
237245 source_git_pr_model = sg_dg .source_git_pull_request
238246 source_git_project = self .service_config .get_project (
@@ -260,7 +268,7 @@ def run(self) -> TaskResults:
260268 check_name = self .status_check_name ,
261269 url = self .status_url ,
262270 )
263- return TaskResults (success = True , details = {} )
271+ return TaskResults (success = True )
264272
265273
266274@reacts_to (event = PipelineGitlabEvent )
0 commit comments