push: Limit remote check to default remote
authorGuido Günther <agx@sigxcpu.org>
Mon, 16 May 2022 08:36:07 +0000 (10:36 +0200)
committerGuido Günther <agx@sigxcpu.org>
Mon, 16 May 2022 08:56:49 +0000 (10:56 +0200)
We can't assume the user is pushing to the defaulte remote as

   gbp push foo

is also supported hence we can't just check pristine-tar status on the
default merge branch.

Helps 2405e158 ("push: skip pristine-tar push if already present remotely")

Gbp-Dch: Ignore

gbp/scripts/push.py

index 494d7eb24a79150865b1714c666f5e7239eccd78..f1c7a59d1b752386072c1b15b0e30e49d75af075 100755 (executable)
@@ -172,11 +172,16 @@ def main(argv):
             if options.pristine_tar:
                 commit, _ = repo.get_pristine_tar_commit(source)
                 if commit:
-                    target = repo.get_merge_branch('pristine-tar')
-                    if not repo.branch_contains(target, commit, remote=True):
-                        ref = 'refs/heads/pristine-tar'
+                    ref = 'refs/heads/pristine-tar'
+                    # If we push to the default we only push if our notion of the remote
+                    # branch doesn't have the commit already (See #1001163)
+                    if dest == get_remote(repo, repo.branch):
+                        target = repo.get_merge_branch('pristine-tar')
+                        if not repo.branch_contains(target, commit, remote=True):
+                            to_push['refs'].append((ref, get_push_src(repo, ref, commit)))
+                    else:
+                        # TODO: Needs to check remote first, (See #1001163)
                         to_push['refs'].append((ref, get_push_src(repo, ref, commit)))
-
         if do_push(repo, [dest], to_push, dry_run=options.dryrun):
             retval = 0
         else: