Try different dirextories when searching for a ref

This commit is contained in:
David Doblas Jiménez 2024-04-23 17:36:41 +02:00
parent 81bf86d41b
commit de595261e6
1 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import itertools
import operator
import os
import string
from collections import namedtuple
from pathlib import Path, PurePath
@ -129,7 +130,23 @@ def get_commit(oid):
def get_oid(name):
return data.get_ref(name) or name
# Name is ref
refs_to_try = [
f"{name}",
f"refs/{name}",
f"refs/tags/{name}",
f"refs/heads/{name}",
]
for ref in refs_to_try:
if data.get_ref(ref):
return data.get_ref(ref)
# Name is SHA1
is_hex = all(c in string.hexdigits for c in name)
if len(name) == 40 and is_hex:
return name
assert False, f"Unknown name {name}"
def is_ignored(path):