From 15573e228686b0ec4674704d1ded30df6a5c83a5 Mon Sep 17 00:00:00 2001 From: Zohar Meir <33152084+zmeir@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:10:54 +0200 Subject: [PATCH] Fix error in `get_main_pr_languages` when the diff is empty This can happen for example when you have one commit add a line to a file and the next commit deletes that line. Then if those are the only 2 commits in the PR the diff will be empty. --- pr_agent/git_providers/git_provider.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 6f986cf02..9dee9e3c8 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -143,6 +143,9 @@ def get_main_pr_language(languages, files) -> str: if not languages: get_logger().info("No languages detected") return main_language_str + if not files: + get_logger().info("No files in diff") + return main_language_str try: top_language = max(languages, key=languages.get).lower()