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

Function test_reset_soft

test/test_repository.py:352–370  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

350
351
352def test_reset_soft(testrepo: Repository) -> None:
353 ref = '5ebeeebb320790caf276b9fc8b24546d63316533'
354 with (Path(testrepo.workdir) / 'hello.txt').open() as f:
355 lines = f.readlines()
356 assert 'hola mundo\n' in lines
357 assert 'bonjour le monde\n' in lines
358
359 testrepo.reset(ref, ResetMode.SOFT)
360 assert testrepo.head.target == ref
361 with (Path(testrepo.workdir) / 'hello.txt').open() as f:
362 lines = f.readlines()
363 # Soft reset will not reset the working copy
364 assert 'hola mundo\n' in lines
365 assert 'bonjour le monde\n' in lines
366
367 # soft reset will keep changes in the index
368 diff = testrepo.diff(cached=True)
369 with pytest.raises(KeyError):
370 diff[0]
371
372
373def test_reset_mixed(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 2

openMethod · 0.80
diffMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…