added method set_user_config to GitApi

This commit is contained in:
Clemens 2023-03-31 13:43:26 +02:00
parent e69bb6adb0
commit cfa05beae4
3 changed files with 8 additions and 2 deletions

View file

@ -216,8 +216,12 @@ class GitApi():
self.system_api.run_checked('git', 'branch', '--show-current')
return ''.join(self.system_api.stdout).rstrip()
def init(self):
self.system_api.run_checked('git', 'init', '-b', 'main')
def init(self, default_branch: str = "main"):
self.system_api.run_checked('git', 'init', '-b', default_branch)
def set_user_config(self, email: str, name: str):
self.system_api.run_checked('git', 'config', 'user.email', email)
self.system_api.run_checked('git', 'config', 'user.name', name)
def add_file(self, file_path: Path):
self.system_api.run_checked('git', 'add', file_path)

View file

@ -20,6 +20,7 @@ def test_git_api(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
git_api = GitApi()
git_api.init()
git_api.set_user_config("ex.ample@mail.com", "Ex Ample")
git_api.add_file(th.TEST_FILE_NAME)
git_api.commit("MINOR release")

View file

@ -41,6 +41,7 @@ def test_release_mixin(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
git_api = GitApi()
git_api.init()
git_api.set_user_config("ex.ample@mail.com", "Ex Ample")
git_api.add_file(th.TEST_FILE_NAME)
git_api.commit("MAJOR release")