mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
Refactor reaction handling in GitHub provider and update help text in PR tools
This commit is contained in:
@ -347,7 +347,7 @@ class AzureDevopsProvider(GitProvider):
|
||||
def publish_description(self, pr_title: str, pr_body: str):
|
||||
if len(pr_body) > MAX_PR_DESCRIPTION_AZURE_LENGTH:
|
||||
|
||||
usage_guide_text='<details> <summary><strong>✨ Usage guide:</strong></summary><hr>'
|
||||
usage_guide_text='<details> <summary><strong>✨ Describe tool usage guide:</strong></summary><hr>'
|
||||
ind = pr_body.find(usage_guide_text)
|
||||
if ind != -1:
|
||||
pr_body = pr_body[:ind]
|
||||
|
@ -456,28 +456,27 @@ class GithubProvider(GitProvider):
|
||||
if disable_eyes:
|
||||
return None
|
||||
try:
|
||||
reaction = self.pr.get_issue_comment(issue_comment_id).create_reaction("eyes")
|
||||
return reaction.id
|
||||
headers, data_patch = self.pr._requester.requestJsonAndCheck(
|
||||
"POST", f"https://api.github.com/repos/{self.repo}/issues/comments/{issue_comment_id}/reactions",
|
||||
input={"content": "eyes"}
|
||||
)
|
||||
return data_patch.get("id", None)
|
||||
except Exception as e:
|
||||
get_logger().exception(f"Failed to add eyes reaction, error: {e}")
|
||||
try:
|
||||
headers, data_patch = self.pr._requester.requestJsonAndCheck(
|
||||
"POST", f"https://api.github.com/repos/{self.repo}/pulls/comments/{issue_comment_id}/reactions",
|
||||
input={"content": "eyes"}
|
||||
)
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool:
|
||||
def remove_reaction(self, issue_comment_id: int, reaction_id: str) -> bool:
|
||||
try:
|
||||
self.pr.get_issue_comment(issue_comment_id).delete_reaction(reaction_id)
|
||||
# self.pr.get_issue_comment(issue_comment_id).delete_reaction(reaction_id)
|
||||
headers, data_patch = self.pr._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
f"https://api.github.com/repos/{self.repo}/issues/comments/{issue_comment_id}/reactions/{reaction_id}"
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
get_logger().exception(f"Failed to remove eyes reaction, error: {e}")
|
||||
return False
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _parse_pr_url(pr_url: str) -> Tuple[str, int]:
|
||||
parsed_url = urlparse(pr_url)
|
||||
|
Reference in New Issue
Block a user