handle git author correctly

This commit is contained in:
2023-08-08 17:31:17 +03:00
parent 1f2d56e605
commit c0930a8995
6 changed files with 46 additions and 24 deletions

View File

@ -145,7 +145,7 @@ def test_init(mocker: MockerFixture) -> None:
check_output_mock.assert_called_once_with("git", "init", "--initial-branch", Sources.DEFAULT_BRANCH,
cwd=local, logger=pytest.helpers.anyvar(int))
add_mock.assert_called_once_with(local, "PKGBUILD", ".SRCINFO", "local")
commit_mock.assert_called_once_with(local, author="ahriman <ahriman@localhost>")
commit_mock.assert_called_once_with(local, commit_author=("ahriman", "ahriman@localhost"))
def test_load(package_ahriman: Package, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
@ -219,11 +219,11 @@ def test_push(package_ahriman: Package, mocker: MockerFixture) -> None:
commit_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.commit")
check_output_mock = mocker.patch("ahriman.core.build_tools.sources.Sources._check_output")
author = "commit author <user@host>"
commit_author = ("commit author", "user@host")
local = Path("local")
Sources.push(Path("local"), package_ahriman.remote, "glob", commit_author=author)
Sources.push(Path("local"), package_ahriman.remote, "glob", commit_author=commit_author)
add_mock.assert_called_once_with(local, "glob")
commit_mock.assert_called_once_with(local, author=author)
commit_mock.assert_called_once_with(local, commit_author=commit_author)
check_output_mock.assert_called_once_with(
"git", "push", package_ahriman.remote.git_url, package_ahriman.remote.branch,
cwd=local, logger=pytest.helpers.anyvar(int))
@ -280,7 +280,8 @@ def test_commit(sources: Sources, mocker: MockerFixture) -> None:
message = "Commit message"
sources.commit(local, message=message)
check_output_mock.assert_called_once_with(
"git", "commit", "--allow-empty", "--message", message, cwd=local, logger=pytest.helpers.anyvar(int)
"git", "commit", "--allow-empty", "--message", message,
cwd=local, logger=pytest.helpers.anyvar(int), environment={}
)
@ -292,11 +293,16 @@ def test_commit_author(sources: Sources, mocker: MockerFixture) -> None:
local = Path("local")
message = "Commit message"
author = "commit author <user@host>"
sources.commit(Path("local"), message=message, author=author)
author = ("commit author", "user@host")
sources.commit(Path("local"), message=message, commit_author=author)
check_output_mock.assert_called_once_with(
"git", "commit", "--allow-empty", "--message", message, "--author", author,
cwd=local, logger=pytest.helpers.anyvar(int)
"git", "commit", "--allow-empty", "--message", message,
cwd=local, logger=pytest.helpers.anyvar(int), environment={
"GIT_AUTHOR_NAME": "commit author",
"GIT_AUTHOR_EMAIL": "user@host",
"GIT_COMMITTER_NAME": "commit author",
"GIT_COMMITTER_EMAIL": "user@host",
}
)
@ -310,7 +316,7 @@ def test_commit_autogenerated_message(sources: Sources, mocker: MockerFixture) -
sources.commit(Path("local"))
check_output_mock.assert_called_once_with(
"git", "commit", "--allow-empty", "--message", pytest.helpers.anyvar(str, strict=True),
cwd=local, logger=pytest.helpers.anyvar(int)
cwd=local, logger=pytest.helpers.anyvar(int), environment={}
)

View File

@ -48,7 +48,8 @@ target = gitremote
target = gitremote
[gitremote]
commit_author = "user <user@host>"
commit_user = user
commit_email = user@host
push_url = https://github.com/arcan1s/repository.git
pull_url = https://github.com/arcan1s/repository.git