Commit messages in pr-description

This commit is contained in:
mrT23
2023-08-01 15:15:59 +03:00
parent 6605f9c444
commit 8c0370a166
5 changed files with 31 additions and 2 deletions

View File

@ -343,4 +343,19 @@ class GithubProvider(GitProvider):
return [label.name for label in self.pr.labels]
except Exception as e:
logging.exception(f"Failed to get labels, error: {e}")
return []
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 = 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