Try different dirextories when searching for a ref
This commit is contained in:
parent
81bf86d41b
commit
de595261e6
19
ugit/base.py
19
ugit/base.py
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user