9th December 2021
Coding⚑
Python⚑
GitPython⚑
-
New: Create a branch.
new_branch = repo.create_head('new_branch') assert repo.active_branch != new_branch # It's not checked out yet repo.head.reference = new_branch assert not repo.head.is_detached
-
New: Get the latest commit of a repository.
repo.head.object.hexsha
Python Snippets⚑
-
New: Copy a directory.
import shutil shutil.copytree('bar', 'foo')
-
Correction: Use fixture to change the working directory of a test.
The previous code didn't work, instead use the next fixture:
@pytest.fixture(name="change_test_dir") def change_test_dir_(request: SubRequest) -> Any: os.chdir(request.fspath.dirname) yield os.chdir(request.config.invocation_dir)