From b8b996d1f134f78f4cc4ff86b08bb2a299e4aaee Mon Sep 17 00:00:00 2001 From: Eli Kogan-Wang Date: Tue, 29 Oct 2024 09:45:06 +0100 Subject: [PATCH] GitBundleRepository._ship: bundle everything and ignore remote head if current head is not in local branch --- src/batou/repository.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/batou/repository.py b/src/batou/repository.py index 2467cd11..58bee26f 100644 --- a/src/batou/repository.py +++ b/src/batou/repository.py @@ -386,13 +386,20 @@ def _ship(self, host): class GitBundleRepository(GitRepository): def _ship(self, host): head = host.rpc.git_current_head() + if head: + # check if head is in local branch, if not, bundle everything and ignore remote head + try: + cmd( + f"git branch {self.branch} --contains {head}", + acceptable_returncodes=[0], + ) + except CmdExecutionError: + head = None if head is None: bundle_range = self.branch else: head = head.decode("ascii") - bundle_range = "{head}..{branch}".format( - head=head, branch=self.branch - ) + bundle_range = f"{head}..{self.branch}" fd, bundle_file = tempfile.mkstemp() os.close(fd) try: