@@ -144,47 +144,51 @@ def process_issue(input: str, repo: str, label: str, number: int, state: str, ou
144144
145145 for issue in get_issues (repository_name = repo , label = label , number = number , state = state ):
146146 # Make sure ontobot_change_agent needs to be triggered or no.
147- if re .match (r"(.*)ontobot(.*)apply(.*):(.*)" , issue [BODY ]):
148- bullet_starters = ["* " , "- " ]
149- KGCL_COMMANDS = []
150- for bullet in bullet_starters :
151-
152- KGCL_COMMANDS .extend (
153- [
154- str (item ).replace (bullet , "" )
155- for item in issue [BODY ].splitlines ()
156- if item .startswith (bullet )
157- ]
158- )
159- if output :
160- new_output = output
147+ if issue :
148+ if re .match (r"(.*)ontobot(.*)apply(.*):(.*)" , issue [BODY ]):
149+ bullet_starters = ["* " , "- " ]
150+ KGCL_COMMANDS = []
151+ for bullet in bullet_starters :
152+
153+ KGCL_COMMANDS .extend (
154+ [
155+ str (item ).replace (bullet , "" )
156+ for item in issue [BODY ].splitlines ()
157+ if item .startswith (bullet )
158+ ]
159+ )
160+ if output :
161+ new_output = output
162+ else :
163+ new_output = input
164+
165+ KGCL_COMMANDS = [x .strip () for x in KGCL_COMMANDS ]
166+ if issue ["number" ] == number and len (KGCL_COMMANDS ) > 0 : # noqa W503 # noqa W503
167+ process_issue_via_oak (
168+ input = input ,
169+ commands = KGCL_COMMANDS ,
170+ output = new_output ,
171+ )
172+
173+ formatted_body += _list_to_markdown (KGCL_COMMANDS )
174+ formatted_body += "</br>Fixes #" + str (issue ["number" ])
175+ # TODO: remove `set-output` when env var setting is confirmed.
176+ if os .getenv ("GITHUB_ENV" ):
177+ with open (os .getenv ("GITHUB_ENV" ), "a" ) as env : # type: ignore
178+ print (f"PR_BODY={ formatted_body } " , file = env )
179+ print (f"PR_TITLE={ issue [TITLE ]} " , file = env )
180+
181+ click .echo (
182+ f"""
183+ PR_BODY={ formatted_body }
184+ PR_TITLE={ issue [TITLE ]}
185+ """
186+ )
161187 else :
162- new_output = input
163-
164- KGCL_COMMANDS = [x .strip () for x in KGCL_COMMANDS ]
165- if issue ["number" ] == number and len (KGCL_COMMANDS ) > 0 : # noqa W503 # noqa W503
166- process_issue_via_oak (
167- input = input ,
168- commands = KGCL_COMMANDS ,
169- output = new_output ,
170- )
171-
172- formatted_body += _list_to_markdown (KGCL_COMMANDS )
173- formatted_body += "</br>Fixes #" + str (issue ["number" ])
174- # TODO: remove `set-output` when env var setting is confirmed.
175- if os .getenv ("GITHUB_ENV" ):
176- with open (os .getenv ("GITHUB_ENV" ), "a" ) as env : # type: ignore
177- print (f"PR_BODY={ formatted_body } " , file = env )
178- print (f"PR_TITLE={ issue [TITLE ]} " , file = env )
179-
180- click .echo (
181- f"""
182- PR_BODY={ formatted_body }
183- PR_TITLE={ issue [TITLE ]}
184- """
185- )
188+ click .echo (f"""{ issue [TITLE ]} does not need ontobot's attention.""" )
186189 else :
187- click .echo (f"""{ issue [TITLE ]} does not need ontobot's attention.""" )
190+ click .echo (f"""Issue number:{ number } is either closed or does not exist.""" )
191+ break
188192
189193
190194def _list_to_markdown (list : list ) -> str :
0 commit comments