get_commit_messages for gitlab

This commit is contained in:
mrT23
2023-08-01 15:30:14 +03:00
parent 8c0370a166
commit dfb73c963a
2 changed files with 14 additions and 3 deletions

View File

@ -353,7 +353,7 @@ class GithubProvider(GitProvider):
str: A string containing the commit messages of the pull request.
"""
try:
commit_list = list(self.pr.get_commits())
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:

View File

@ -299,5 +299,16 @@ class GitLabProvider(GitProvider):
def get_labels(self):
return self.mr.labels
def get_commit_messages(self):
return "" # not implemented yet
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