diff --git a/forwardport/models/project.py b/forwardport/models/project.py index 2dc83000..87694326 100644 --- a/forwardport/models/project.py +++ b/forwardport/models/project.py @@ -331,11 +331,14 @@ class PullRequests(models.Model): "Forward-porting" if forward else "Back-porting", self.display_name, root.display_name, target_branch.name ) - fetch = source.with_config(stdout=subprocess.PIPE, stderr=subprocess.STDOUT).fetch() - logger.info("Updated cache repo %s:\n%s", source._directory, fetch.stdout.decode()) head_fetch = source.with_config(stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False) \ - .fetch(git.source_url(self.repository), root.head) + .fetch( + git.source_url(self.repository), + f"refs/heads/{target_branch.name}:refs/heads/{target_branch.name}", + root.head, + no_tags=True, + ) if head_fetch.returncode: raise ForwardPortError( f"During forward port of {self.display_name}, unable to find " diff --git a/runbot_merge/models/patcher.py b/runbot_merge/models/patcher.py index 37a83507..d558271f 100644 --- a/runbot_merge/models/patcher.py +++ b/runbot_merge/models/patcher.py @@ -263,7 +263,7 @@ class Patch(models.Model): remote, f"+refs/heads/{target.name}:refs/heads/{target.name}", *(p.commit for p in ps), - no_tags=True + no_tags=True, ).returncode: r.fetch(remote, f"+refs/heads/{target.name}:refs/heads/{target.name}", no_tags=True) for p in ps: diff --git a/runbot_merge/models/stagings_create.py b/runbot_merge/models/stagings_create.py index 7dadd697..5e61a6f4 100644 --- a/runbot_merge/models/stagings_create.py +++ b/runbot_merge/models/stagings_create.py @@ -249,12 +249,7 @@ def staging_setup( source = git.get_local(repo) source.fetch( git.source_url(repo), - # a full refspec is necessary to ensure we actually fetch the ref - # (not just the commit it points to) and update it. - # `git fetch $remote $branch` seems to work locally, but it might - # be hooked only to "proper" remote-tracking branches - # (in `refs/remotes`), it doesn't seem to work here - f'+refs/heads/{target.name}:refs/heads/{target.name}', + head, *(pr.head for pr in by_repo.get(repo, [])), no_tags=True, )