From dfb73c963a145fa1cc21f63a8c42e355887658b5 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 1 Aug 2023 15:30:14 +0300 Subject: [PATCH] get_commit_messages for gitlab --- pr_agent/git_providers/github_provider.py | 2 +- pr_agent/git_providers/gitlab_provider.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index 0e6b85a7..341335df 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -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: diff --git a/pr_agent/git_providers/gitlab_provider.py b/pr_agent/git_providers/gitlab_provider.py index 0e2f293a..279815d6 100644 --- a/pr_agent/git_providers/gitlab_provider.py +++ b/pr_agent/git_providers/gitlab_provider.py @@ -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