added method set_user_config to GitApi
This commit is contained in:
parent
e69bb6adb0
commit
cfa05beae4
3 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue