Skip to content

Commit

Permalink
Merge pull request #320 from Codium-ai/tr/pr_id
Browse files Browse the repository at this point in the history
Implementing get_pr_id method in Git Providers
  • Loading branch information
mrT23 authored Sep 21, 2023
2 parents 0416256 + 3e07fe6 commit d384b06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pr_agent/git_providers/git_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool:
def get_commit_messages(self):
pass

def get_pr_id(self):
return ""

def get_main_pr_language(languages, files) -> str:
"""
Get the main language of the commit. Return an empty string if cannot determine.
Expand Down
7 changes: 7 additions & 0 deletions pr_agent/git_providers/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,10 @@ def generate_link_to_relevant_line_number(self, suggestion) -> str:
logging.info(f"Failed adding line link, error: {e}")

return ""

def get_pr_id(self):
try:
pr_id = f"{self.repo}/{self.pr_num}"
return pr_id
except:
return ""
9 changes: 8 additions & 1 deletion pr_agent/git_providers/gitlab_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,11 @@ def get_commit_messages(self):
commit_messages_str = ""
if max_tokens:
commit_messages_str = clip_tokens(commit_messages_str, max_tokens)
return commit_messages_str
return commit_messages_str

def get_pr_id(self):
try:
pr_id = self.mr.web_url
return pr_id
except:
return ""
2 changes: 1 addition & 1 deletion pr_agent/tools/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, pr_url: str, args: list = None):
self.main_pr_language = get_main_pr_language(
self.git_provider.get_languages(), self.git_provider.get_files()
)
self.pr_id = f"{self.git_provider.repo}/{self.git_provider.pr_num}"
self.pr_id = self.git_provider.get_pr_id()

# Initialize the AI handler
self.ai_handler = AiHandler()
Expand Down

0 comments on commit d384b06

Please sign in to comment.