From b0e171e7c60448852730c5c0b019636bd1090f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schm=C3=B6lder?= Date: Thu, 19 Feb 2026 16:32:04 +0100 Subject: [PATCH] Fix IndexError when local branch has no upstream counterpart --- cadetrdm/repositories.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cadetrdm/repositories.py b/cadetrdm/repositories.py index 0a1215b..33c451a 100644 --- a/cadetrdm/repositories.py +++ b/cadetrdm/repositories.py @@ -179,11 +179,19 @@ def has_changes_upstream(self): try: remote = self.remotes[0] remote_branches = remote.fetch() - correct_remote_branches = [fetch_info for fetch_info in remote_branches - if fetch_info.name == f"{remote.name}/{self.active_branch.name}"] + correct_remote_branches = [ + remote_branch for remote_branch in remote_branches + if remote_branch.name == f"{remote.name}/{self.active_branch.name}" + ] if len(correct_remote_branches) > 1: - raise RuntimeError(f"Remote has multiple branches matching local branch {self.active_branch.name}: " - f"{[branch.name for branch in correct_remote_branches]}") + raise RuntimeError( + f"Remote has multiple branches matching local branch {self.active_branch.name}: " + f"{[branch.name for branch in correct_remote_branches]}" + ) + + if not correct_remote_branches: + print(f"Branch {self.active_branch.name} does not exist upstream yet.") + return False remote_hash = str(correct_remote_branches[0].commit) if self.current_commit_hash != remote_hash and remote_hash not in self.log: