Skip to content

Commit 28c275d

Browse files
authored
Merge pull request #43 from hrshdhgd/check-need
Check if ontobot is needed or no.
2 parents 00ce99a + 522f6d3 commit 28c275d

File tree

1 file changed

+37
-32
lines changed
  • src/ontobot_change_agent

1 file changed

+37
-32
lines changed

src/ontobot_change_agent/cli.py

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""Command line interface for :mod:`ontobot_change_agent`."""
44

55
import logging
6+
import re
67
from typing import TextIO
78

89
import click
@@ -141,39 +142,43 @@ def process_issue(input: str, repo: str, label: str, number: int, state: str, ou
141142
formatted_body = "The following commands were executed: </br>"
142143

143144
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+
)
157180
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.""")
177182

178183

179184
def _list_to_markdown(list: list) -> str:

0 commit comments

Comments
 (0)