Skip to content

Commit a020ecb

Browse files
committed
Merge branch 'bug1962304/fetchrepo_improvements' into develop
2 parents 4767968 + e4419df commit a020ecb

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

git_hg_sync/repo_synchronizer.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,23 @@ def sync(
116116
# Create tag branches locally
117117
tag_branches = {op.tags_destination_branch for op in tag_ops}
118118
for tag_branch in tag_branches:
119-
retry(
120-
"getting tag branch from destination",
121-
# https://docs.python-guide.org/writing/gotchas/#late-binding-closures
122-
partial(
123-
repo.git.fetch,
124-
[
125-
"-f",
126-
destination_remote,
127-
f"refs/heads/branches/{tag_branch}/tip:{tag_branch}",
128-
],
129-
),
130-
)
119+
remote_tag_ref = f"refs/heads/branches/{tag_branch}/tip"
120+
if repo.git.execute(
121+
["git", "ls-remote", destination_remote, remote_tag_ref],
122+
stdout_as_string=True,
123+
):
124+
retry(
125+
"getting tag branch from destination",
126+
# https://docs.python-guide.org/writing/gotchas/#late-binding-closures
127+
partial(
128+
repo.git.fetch,
129+
[
130+
"-f",
131+
destination_remote,
132+
f"{remote_tag_ref}:{tag_branch}",
133+
],
134+
),
135+
)
131136
push_args.append(f"{tag_branch}:refs/heads/branches/{tag_branch}/tip")
132137

133138
# Create tags

0 commit comments

Comments
 (0)