mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
Merge remote-tracking branch 'origin/main' into ok/settings_refactor
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
## 2023-08-01
|
||||
|
||||
### Enhanced
|
||||
- Introduced the ability to retrieve commit messages from pull requests across different git providers.
|
||||
- Implemented commit messages retrieval for GitHub and GitLab providers.
|
||||
- Updated the PR description template to include a section for commit messages if they exist.
|
||||
|
||||
## 2023-07-30
|
||||
|
||||
### Enhanced
|
||||
|
@ -120,3 +120,6 @@ class BitbucketProvider:
|
||||
|
||||
def _get_pr_file_content(self, remote_link: str):
|
||||
return ""
|
||||
|
||||
def get_commit_messages(self):
|
||||
return "" # not implemented yet
|
||||
|
@ -345,3 +345,18 @@ class GithubProvider(GitProvider):
|
||||
except Exception as e:
|
||||
logging.exception(f"Failed to get labels, error: {e}")
|
||||
return []
|
||||
|
||||
def get_commit_messages(self) -> str:
|
||||
"""
|
||||
Retrieves the commit messages of a pull request.
|
||||
|
||||
Returns:
|
||||
str: A string containing the commit messages of the pull request.
|
||||
"""
|
||||
try:
|
||||
commit_list = self.pr.get_commits()
|
||||
commit_messages = [commit.commit.message for commit in commit_list]
|
||||
commit_messages_str = "\n".join([f"{i + 1}. {message}" for i, message in enumerate(commit_messages)])
|
||||
except:
|
||||
commit_messages_str = ""
|
||||
return commit_messages_str
|
||||
|
@ -297,3 +297,17 @@ class GitLabProvider(GitProvider):
|
||||
|
||||
def get_labels(self):
|
||||
return self.mr.labels
|
||||
|
||||
def get_commit_messages(self) -> str:
|
||||
"""
|
||||
Retrieves the commit messages of a pull request.
|
||||
|
||||
Returns:
|
||||
str: A string containing the commit messages of the pull request.
|
||||
"""
|
||||
try:
|
||||
commit_messages_list = [commit['message'] for commit in self.mr.commits()._list]
|
||||
commit_messages_str = "\n".join([f"{i + 1}. {message}" for i, message in enumerate(commit_messages_list)])
|
||||
except:
|
||||
commit_messages_str = ""
|
||||
return commit_messages_str
|
||||
|
@ -36,8 +36,14 @@ Don't repeat the prompt in the answer, and avoid outputting the 'type' and 'desc
|
||||
user="""PR Info:
|
||||
Branch: '{{branch}}'
|
||||
{%- if language %}
|
||||
|
||||
Main language: {{language}}
|
||||
{%- endif %}
|
||||
{%- if commit_messages_str %}
|
||||
|
||||
Commit messages:
|
||||
{{commit_messages_str}}
|
||||
{%- endif %}
|
||||
|
||||
|
||||
The PR Git Diff:
|
||||
|
@ -27,6 +27,7 @@ class PRDescription:
|
||||
self.main_pr_language = get_main_pr_language(
|
||||
self.git_provider.get_languages(), self.git_provider.get_files()
|
||||
)
|
||||
commit_messages_str = self.git_provider.get_commit_messages()
|
||||
|
||||
# Initialize the AI handler
|
||||
self.ai_handler = AiHandler()
|
||||
@ -39,6 +40,7 @@ class PRDescription:
|
||||
"language": self.main_pr_language,
|
||||
"diff": "", # empty diff for initial calculation
|
||||
"extra_instructions": get_settings().pr_description.extra_instructions,
|
||||
"commit_messages_str": commit_messages_str
|
||||
}
|
||||
|
||||
# Initialize the token handler
|
||||
|
Reference in New Issue
Block a user