scripts/git-cherry-gerrit.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
New commits: commit 3ce714de3b5319efeee3f713c82d58649b3e0098 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Feb 24 10:59:18 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 24 10:00:57 2023 +0000 git-cherry-gerrit.py: fix crash when the rev-list output is empty Traceback (most recent call last): File "git-cherry-gerrit.py", line 103, in <module> main() File "git-cherry-gerrit.py", line 83, in main changeid = get_change_id(git_cat_file, from_hash) File "git-cherry-gerrit.py", line 29, in get_change_id size = first_line.strip().split(" ")[2] IndexError: list index out of range Change-Id: Icc53d038ceebc690998dc14da15f7b1b9ac4f341 Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/147618 Tested-by: Miklos Vajna <vmik...@collabora.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/scripts/git-cherry-gerrit.py b/scripts/git-cherry-gerrit.py index bb8235fa..9ee285b2 100755 --- a/scripts/git-cherry-gerrit.py +++ b/scripts/git-cherry-gerrit.py @@ -74,7 +74,11 @@ def main() -> None: for to_hash in to_hashes: to_change_ids.append(get_change_id(git_cat_file, to_hash)) - from_hashes = from_pipe(["git", "rev-list", branch_point + ".." + cherry_from]).split("\n") + from_hashes = [] + buffer = from_pipe(["git", "rev-list", branch_point + ".." + cherry_from]) + # If there are no commits, we want an empty list, not a list with one empty item. + if buffer: + from_hashes = buffer.split("\n") whitelist: List[str] = [] if whitelist_file: with open(whitelist_file, "r") as stream: