Skip to content

Commit ad9d79f

Browse files
codexByron
authored andcommitted
feat(gix): resolve revisions and repository metadata natively
Handle verified revisions and bound repository metadata with GixPython. Keep Git's initial repository validation and unsupported discovery options. Message searches, dirty suffixes and describe-shaped names fall back because the native grammar differs in regex handling and exact-tag precedence (GIX-14/17). The staged version passes Ruff and Python syntax checks. Its SHA-1/SHA-256 native smoke and focused pytest selection pass: 26 passed in 18.03s.
1 parent 3b6be62 commit ad9d79f

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎git/_backend.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,27 @@ def object_data(command: Any, ref: bytes, *, stream: bool = False) -> Any:
124124
return result
125125

126126

127-
_HANDLERS: Dict[str, Callable[[Any, List[str], Dict[str, Any]], bytes]] = {}
127+
def _rev_parse(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes:
128+
if args == ["--path-format=absolute", "--git-common-dir"]:
129+
return os.fsencode(os.path.abspath(repo.common_dir())) + b"\n"
130+
if args == ["--is-bare-repository"]:
131+
return b"true\n" if repo.is_bare() else b"false\n"
132+
if args == ["--show-object-format"]:
133+
return str(repo.object_hash()).encode("ascii") + b"\n"
134+
if args == ["--show-ref-format"]:
135+
return b"files\n" # _repository rejects reftable before dispatch.
136+
if args == ["--show-toplevel"] and repo.workdir() is not None:
137+
return os.fsencode(os.path.abspath(repo.workdir())) + b"\n"
138+
if args[:1] != ["--verify"] or args[-2:-1] != ["--end-of-options"]:
139+
raise _Unsupported("discovery or revision options")
140+
if args[:-2] not in (["--verify"], ["--verify", "--quiet"]):
141+
raise _Unsupported("revision options")
142+
return str(_oid(repo, args[-1])).encode("ascii") + b"\n"
143+
144+
145+
_HANDLERS: Dict[str, Callable[[Any, List[str], Dict[str, Any]], bytes]] = {
146+
"rev_parse": _rev_parse,
147+
}
128148

129149

130150
def dispatch(

0 commit comments

Comments
 (0)