MCPcopy Create free account
hub / github.com/libgit2/pygit2 / resolve_refish

Method resolve_refish

pygit2/repository.py:367–389  ·  view source on GitHub ↗

Convert a reference-like short name "ref-ish" to a valid (commit, reference) pair. If ref-ish points to a commit, the reference element of the result will be None. Examples:: repo.resolve_refish('mybranch') repo.resolve_refish('sometag')

(self, refish: str)

Source from the content-addressed store, hash-verified

365 return list(x for x in self.references.iterator())
366
367 def resolve_refish(self, refish: str) -> tuple[Commit, Reference]:
368 """Convert a reference-like short name "ref-ish" to a valid
369 (commit, reference) pair.
370
371 If ref-ish points to a commit, the reference element of the result
372 will be None.
373
374 Examples::
375
376 repo.resolve_refish('mybranch')
377 repo.resolve_refish('sometag')
378 repo.resolve_refish('origin/master')
379 repo.resolve_refish('bbb78a9')
380 """
381 try:
382 reference = self.lookup_reference_dwim(refish)
383 except (KeyError, InvalidSpecError):
384 reference = None
385 commit = self.revparse_single(refish)
386 else:
387 commit = reference.peel(Commit) # type: ignore
388
389 return (commit, reference) # type: ignore
390
391 def transaction(self) -> ReferenceTransaction:
392 """Create a new reference transaction.

Callers 1

test_resolve_refishFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_resolve_refishFunction · 0.64