|
3 | 3 | """Command line interface for :mod:`ontobot_change_agent`.""" |
4 | 4 |
|
5 | 5 | import logging |
| 6 | +import re |
6 | 7 | from typing import TextIO |
7 | 8 |
|
8 | 9 | import click |
@@ -141,39 +142,43 @@ def process_issue(input: str, repo: str, label: str, number: int, state: str, ou |
141 | 142 | formatted_body = "The following commands were executed: </br>" |
142 | 143 |
|
143 | 144 | for issue in get_issues(repository_name=repo, label=label, number=number, state=state): |
144 | | - bullet_starters = ["* ", "- "] |
145 | | - KGCL_COMMANDS = [] |
146 | | - for bullet in bullet_starters: |
147 | | - |
148 | | - KGCL_COMMANDS.extend( |
149 | | - [ |
150 | | - str(item).replace(bullet, "") |
151 | | - for item in issue[BODY].splitlines() |
152 | | - if item.startswith(bullet) |
153 | | - ] |
154 | | - ) |
155 | | - if output: |
156 | | - new_output = output |
| 145 | + # Make sure ontobot_change_agent needs to be triggered or no. |
| 146 | + if re.match(r"(.*)ontobot(.*)apply(.*):(.*)\*", issue[BODY]): |
| 147 | + bullet_starters = ["* ", "- "] |
| 148 | + KGCL_COMMANDS = [] |
| 149 | + for bullet in bullet_starters: |
| 150 | + |
| 151 | + KGCL_COMMANDS.extend( |
| 152 | + [ |
| 153 | + str(item).replace(bullet, "") |
| 154 | + for item in issue[BODY].splitlines() |
| 155 | + if item.startswith(bullet) |
| 156 | + ] |
| 157 | + ) |
| 158 | + if output: |
| 159 | + new_output = output |
| 160 | + else: |
| 161 | + new_output = input |
| 162 | + |
| 163 | + KGCL_COMMANDS = [x.strip() for x in KGCL_COMMANDS] |
| 164 | + if issue["number"] == number and len(KGCL_COMMANDS) > 0: # noqa W503 # noqa W503 |
| 165 | + process_issue_via_oak( |
| 166 | + input=input, |
| 167 | + commands=KGCL_COMMANDS, |
| 168 | + output=new_output, |
| 169 | + ) |
| 170 | + |
| 171 | + formatted_body += _list_to_markdown(KGCL_COMMANDS) |
| 172 | + formatted_body += "</br>Fixes #" + str(issue["number"]) |
| 173 | + |
| 174 | + click.echo( |
| 175 | + f""" |
| 176 | + ::set-output name=PR_BODY::{formatted_body} |
| 177 | + ::set-output name=PR_TITLE::{issue[TITLE]} |
| 178 | + """ |
| 179 | + ) |
157 | 180 | else: |
158 | | - new_output = input |
159 | | - |
160 | | - KGCL_COMMANDS = [x.strip() for x in KGCL_COMMANDS] |
161 | | - if issue["number"] == number and len(KGCL_COMMANDS) > 0: # noqa W503 # noqa W503 |
162 | | - process_issue_via_oak( |
163 | | - input=input, |
164 | | - commands=KGCL_COMMANDS, |
165 | | - output=new_output, |
166 | | - ) |
167 | | - |
168 | | - formatted_body += _list_to_markdown(KGCL_COMMANDS) |
169 | | - formatted_body += "</br>Fixes #" + str(issue["number"]) |
170 | | - |
171 | | - click.echo( |
172 | | - f""" |
173 | | - ::set-output name=PR_BODY::{formatted_body} |
174 | | - ::set-output name=PR_TITLE::{issue[TITLE]} |
175 | | - """ |
176 | | - ) |
| 181 | + click.echo(f"""{issue[TITLE]} does not need ontobot's attention.""") |
177 | 182 |
|
178 | 183 |
|
179 | 184 | def _list_to_markdown(list: list) -> str: |
|
0 commit comments