Skip to content

Commit

Permalink
Fix error in get_main_pr_languages when the diff is empty
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zmeir committed Nov 2, 2023
1 parent ce64877 commit 15573e2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pr_agent/git_providers/git_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 15573e2

Please sign in to comment.