Skip to content

Commit

Permalink
Don't commment on Github, only eyes reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
okotek committed Aug 7, 2023
1 parent b1148e5 commit ebbe655
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion pr_agent/agent/pr_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PRAgent:
def __init__(self):
pass

async def handle_request(self, pr_url, request) -> bool:
async def handle_request(self, pr_url, request, notify=None) -> bool:
# First, apply repo specific settings if exists
if get_settings().config.use_repo_settings_file:
repo_settings_file = None
Expand Down Expand Up @@ -67,8 +67,12 @@ async def handle_request(self, pr_url, request) -> bool:
if action == "reflect_and_review" and not get_settings().pr_reviewer.ask_and_reflect:
action = "review"
if action == "answer":
if notify:
notify()
await PRReviewer(pr_url, is_answer=True, args=args).run()
elif action in command2class:
if notify:
notify()
await command2class[action](pr_url, args=args).run()
else:
return False
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/servers/github_action_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async def run_action():
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
get_settings().set("CONFIG.PUBLISH_OUTPUT_PROGRESS", False)


# Check if required environment variables are set
if not GITHUB_EVENT_NAME:
print("GITHUB_EVENT_NAME not set")
Expand Down Expand Up @@ -65,8 +66,7 @@ async def run_action():
body = comment_body.strip().lower()
comment_id = event_payload.get("comment", {}).get("id")
provider = get_git_provider()(pr_url=pr_url)
provider.add_eyes_reaction(comment_id)
await PRAgent().handle_request(pr_url, body)
await PRAgent().handle_request(pr_url, body, notify=lambda: provider.add_eyes_reaction(comment_id))


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions pr_agent/servers/github_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ async def handle_request(body: Dict[str, Any]):
api_url = pull_request.get("url")
comment_id = body.get("comment", {}).get("id")
provider = get_git_provider()(pr_url=api_url)
provider.add_eyes_reaction(comment_id)
await agent.handle_request(api_url, comment_body)
await agent.handle_request(api_url, comment_body, notify=lambda: provider.add_eyes_reaction(comment_id))


elif action == "opened" or 'reopened' in action:
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/servers/github_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ async def polling_loop():
rest_of_comment = comment_body.split(user_tag)[1].strip()
comment_id = comment['id']
git_provider.set_pr(pr_url)
git_provider.add_eyes_reaction(comment_id)
success = await agent.handle_request(pr_url, rest_of_comment)
success = await agent.handle_request(pr_url, rest_of_comment,
notify=lambda: git_provider.add_eyes_reaction(comment_id)) # noqa E501
if not success:
git_provider.set_pr(pr_url)
git_provider.publish_comment("### How to use PR-Agent\n" +
Expand Down

0 comments on commit ebbe655

Please sign in to comment.