fix: handle empty commits and errors in GitLab provider's get_latest_commit_url

This commit is contained in:
mrT23
2025-02-26 21:24:53 +02:00
parent c7f4b87d6f
commit 9a9acef0e8

View File

@ -181,7 +181,13 @@ class GitLabProvider(GitProvider):
get_logger().exception(f"Could not update merge request {self.id_mr} description: {e}") get_logger().exception(f"Could not update merge request {self.id_mr} description: {e}")
def get_latest_commit_url(self): def get_latest_commit_url(self):
return self.mr.commits().next().web_url try:
return self.mr.commits().next().web_url
except StopIteration: # no commits
return ""
except Exception as e:
get_logger().exception(f"Could not get latest commit URL: {e}")
return ""
def get_comment_url(self, comment): def get_comment_url(self, comment):
return f"{self.mr.web_url}#note_{comment.id}" return f"{self.mr.web_url}#note_{comment.id}"