roll_util: Handle empty commit messages

Change-Id: I7fce633fb727d23118d24b592a16cf8412158e1b
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/120452
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
diff --git a/recipe_modules/roll_util/api.py b/recipe_modules/roll_util/api.py
index 3640e4d..e20b7ea 100644
--- a/recipe_modules/roll_util/api.py
+++ b/recipe_modules/roll_util/api.py
@@ -415,10 +415,14 @@
 {project_name} Rolled-Commits: {old_revision:.15}..{new_revision:.15}
     """.strip()
 
-        one_liners = [
-            '{:.15} {}'.format(commit.hash, commit.message.splitlines()[0][:50])
-            for commit in roll.commits
-        ]
+        one_liners = []
+        for commit in roll.commits:
+            # Handle case where the commit message is empty. Example:
+            # https://github.com/google/googletest/commit/148ab827cacc7a879832f40313bda87a65b1e8a3
+            first_line = '(empty commit message)'
+            if commit.message:
+                first_line = commit.message.splitlines()[0]
+            one_liners.append(f'{commit.hash:.15} {first_line[0:50]}')
 
         num_commits = len(roll.commits)