fix: ref_exists also checks git-svn remote ref variant for imported tags/branches

This commit is contained in:
2026-06-23 22:19:12 +02:00
parent 4d6326231b
commit 2cb6a4b230
2 changed files with 12 additions and 21 deletions
+1 -20
View File
@@ -362,29 +362,10 @@ class Mirror:
return git_ref
def _write_mappings_to_db(self, mappings: List[Tuple[int, str, str, str]]):
"""Bulk-insert parsed mappings into SQLite.
Also records entries for converted refs (e.g. refs/remotes/origin/tags/*
→ refs/tags/*) so that git_to_svn push logic doesn't re-push them.
"""
"""Bulk-insert parsed mappings into SQLite."""
logger.info("Writing %d mapping entries to DB…", len(mappings))
for rev, sha, branch, ref in mappings:
self.db.record_mapping(rev, sha, branch, ref, source="svn")
# Also record the converted ref if this is a tag
tag_prefix = "refs/remotes/origin/tags/"
if ref.startswith(tag_prefix):
tag_name = ref[len(tag_prefix):]
tag_ref = f"refs/tags/{tag_name}"
self.db.record_mapping(rev, sha, branch, tag_ref, source="svn")
# Convert branch refs too
br_prefix = "refs/remotes/origin/"
if ref.startswith(br_prefix) and not ref.startswith(tag_prefix):
rest = ref[len(br_prefix):]
if rest == "trunk":
head_ref = "refs/heads/master"
else:
head_ref = f"refs/heads/{rest}"
self.db.record_mapping(rev, sha, branch, head_ref, source="svn")
logger.info("Mapping DB now has %d entries", self.db.mapping_count())
def _finalize_import_state(self):