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

Function test_resolve_refish

test/test_refs.py:498–537  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

496
497
498def test_resolve_refish(testrepo: Repository) -> None:
499 repo = testrepo
500
501 # remote ref
502 reference = testrepo.create_reference('refs/remotes/origin/master', LAST_COMMIT)
503 assert reference.shorthand == 'origin/master'
504 # tag
505 repo.create_reference('refs/tags/version1', LAST_COMMIT)
506
507 # Test dwim lookups
508
509 # Raise KeyError ?
510 with pytest.raises(KeyError):
511 repo.resolve_refish('foo')
512 with pytest.raises(KeyError):
513 repo.resolve_refish('refs/foo')
514
515 commit, ref = repo.resolve_refish('refs/heads/i18n')
516 assert ref.name == 'refs/heads/i18n'
517 assert commit.id == '5470a671a80ac3789f1a6a8cefbcf43ce7af0563'
518
519 commit, ref = repo.resolve_refish('master')
520 assert ref.name == 'refs/heads/master'
521 assert commit.id == LAST_COMMIT
522
523 commit, ref = repo.resolve_refish('origin/master')
524 assert ref.name == 'refs/remotes/origin/master'
525 assert commit.id == LAST_COMMIT
526
527 commit, ref = repo.resolve_refish('version1')
528 assert ref.name == 'refs/tags/version1'
529 assert commit.id == LAST_COMMIT
530
531 commit, ref = repo.resolve_refish(LAST_COMMIT)
532 assert ref is None
533 assert commit.id == LAST_COMMIT
534
535 commit, ref = repo.resolve_refish('HEAD~1')
536 assert ref is None
537 assert commit.id == '5ebeeebb320790caf276b9fc8b24546d63316533'
538
539
540def test_reference_get_sha(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 2

create_referenceMethod · 0.80
resolve_refishMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…