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
+11 -1
View File
@@ -103,8 +103,18 @@ class MappingDB:
).fetchall()
def ref_exists(self, git_ref: str) -> bool:
# Also check the git-svn remote variant if this is a canonical ref
variants = [git_ref]
if git_ref.startswith("refs/tags/"):
variants.append("refs/remotes/origin/tags/" + git_ref[10:])
elif git_ref == "refs/heads/master":
variants.append("refs/remotes/origin/trunk")
elif git_ref.startswith("refs/heads/"):
variants.append("refs/remotes/origin/" + git_ref[11:])
row = self.conn.execute(
"SELECT 1 FROM svn_to_git WHERE git_ref=?", (git_ref,)
"SELECT 1 FROM svn_to_git WHERE git_ref IN ({})".format(
",".join("?" * len(variants))
), variants
).fetchone()
return row is not None