diff --git a/tagbot/action/git.py b/tagbot/action/git.py index 6dfc5420..52f4f6cc 100644 --- a/tagbot/action/git.py +++ b/tagbot/action/git.py @@ -94,6 +94,8 @@ def config(self, key: str, val: str) -> None: def create_tag(self, version: str, sha: str, message: str) -> None: """Create and push a Git tag.""" + self.config("user.name", "github-actions[bot]") + self.config("user.email", "actions@github.com") self.command("tag", "-m", message, version, sha) self.command("push", "origin", version) diff --git a/tagbot/action/repo.py b/tagbot/action/repo.py index da5f0474..06ea76cb 100644 --- a/tagbot/action/repo.py +++ b/tagbot/action/repo.py @@ -300,8 +300,6 @@ def configure_gpg(self, key: str, password: Optional[str]) -> None: warn(sign_result.stderr) raise Abort("Testing GPG key failed") self._git.config("user.signingKey", key_id) - self._git.config("user.name", "github-actions[bot]") - self._git.config("user.email", "actions@github.com") self._git.config("tag.gpgSign", "true") def handle_release_branch(self, version: str) -> None: diff --git a/test/action/test_git.py b/test/action/test_git.py index 27774247..53568d57 100644 --- a/test/action/test_git.py +++ b/test/action/test_git.py @@ -106,8 +106,17 @@ def test_config(): def test_create_tag(): g = _git(command="hm") + g.config = Mock() g.create_tag("v1", "abcdef", "log") - calls = [call("tag", "-m", "log", "v1", "abcdef"), call("push", "origin", "v1")] + calls = [ + call("user.name", "github-actions[bot]"), + call("user.email", "actions@github.com"), + ] + g.config.assert_has_calls(calls) + calls = [ + call("tag", "-m", "log", "v1", "abcdef"), + call("push", "origin", "v1"), + ] g.command.assert_has_calls(calls) diff --git a/test/action/test_repo.py b/test/action/test_repo.py index 166c3ccb..6097e6ee 100644 --- a/test/action/test_repo.py +++ b/test/action/test_repo.py @@ -319,12 +319,7 @@ def test_configure_gpg(chmod, mkdtemp, GPG): chmod.assert_called_with("gpgdir", S_IREAD | S_IWRITE | S_IEXEC) GPG.assert_called_with(gnupghome="gpgdir", use_agent=True) gpg.import_keys.assert_called_with("foo bar") - calls = [ - call("user.signingKey", "k"), - call("user.name", "github-actions[bot]"), - call("user.email", "actions@github.com"), - call("tag.gpgSign", "true"), - ] + calls = [call("user.signingKey", "k"), call("tag.gpgSign", "true")] r._git.config.assert_has_calls(calls) r.configure_gpg("Zm9v", None) gpg.import_keys.assert_called_with("foo")