From f6606787ef0c81bf0fb8738779896ed2cf91c2ca Mon Sep 17 00:00:00 2001 From: Maxine Hayes Date: Thu, 10 Aug 2023 09:59:53 -0400 Subject: [PATCH] Fix 'IndexError: list index out of range' error when working with a completely empty Gitlab repository. --- pv2/util/gitutil.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pv2/util/gitutil.py b/pv2/util/gitutil.py index 504d7b4..f66cbc1 100644 --- a/pv2/util/gitutil.py +++ b/pv2/util/gitutil.py @@ -153,5 +153,9 @@ def lsremote(url): for ref in git_cmd.ls_remote(url).split('\n'): hash_ref_list = ref.split('\t') - remote_refs[hash_ref_list[1]] = hash_ref_list[0] + # Solves "IndexError: list index out of range" error when working + # with a completely empty Gitlab repository. + # (Initialized without README in the web interface) + if len(hash_ref_list) > 1: + remote_refs[hash_ref_list[1]] = hash_ref_list[0] return remote_refs