Skip to content

Commit

Permalink
Fix: Releasing GoLang projects
Browse files Browse the repository at this point in the history
Sq
  • Loading branch information
y0urself committed Feb 10, 2023
1 parent 3790cb0 commit aa0abb6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pontos/git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def commit(
verify: Set to False to skip git hooks
gpg_signing_key: GPG Key ID to use to sign the commit
"""
args = ["commit", "--verbose"]
args = ["commit"]
if verify is False:
args.append("--no-verify")
if gpg_signing_key:
Expand Down
3 changes: 3 additions & 0 deletions pontos/release/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pontos.git import Git, GitError
from pontos.terminal import Terminal
from pontos.version import COMMANDS
from pontos.version.go import GoVersionCommand
from pontos.version.helper import VersionError

DEFAULT_TIMEOUT = 1000
Expand Down Expand Up @@ -229,6 +230,8 @@ def update_version(
command = cmd()
project_file = command.project_file_found()
if project_file:
if isinstance(command, GoVersionCommand):
project_file = Path.cwd() / "version.go"
break

if not project_file:
Expand Down
14 changes: 12 additions & 2 deletions tests/release/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def test_find_no_signing_key(self):
def test_update_version_not_found(self):
terminal = MagicMock()

with temp_directory(change_into=True):
with temp_directory(change_into=True), patch.object(
Git,
"list_tags",
MagicMock(return_value=["21.4.4"]),
):
executed, filename = update_version(
terminal, to="21.4.4", develop=True
)
Expand All @@ -123,7 +127,13 @@ def test_update_version_not_found(self):
def test_update_version_no_version_file(self):
terminal = MagicMock()

with temp_directory(change_into=True, add_to_sys_path=True) as tmp_dir:
with temp_directory(
change_into=True, add_to_sys_path=True
) as tmp_dir, patch.object(
Git,
"list_tags",
MagicMock(return_value=["1.2.3"]),
):
module_path = tmp_dir / "testrepo"
module_path.mkdir(parents=True, exist_ok=True)

Expand Down
3 changes: 3 additions & 0 deletions tests/version/test_go_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def test_no_file_but_tag_update_version(self):
self.assertIn(version, content)
self.assertEqual(updated_version_obj.previous, "21.0.1")
self.assertEqual(updated_version_obj.new, version)
version_file_path.unlink()

def test_update_version(self):
with temp_file(
Expand All @@ -161,6 +162,7 @@ def test_update_version(self):

content = version_file_path.read_text(encoding="utf-8")
self.assertIn(version, content)
version_file_path.unlink()

def test_create_file_update_version(self):
with temp_file(
Expand All @@ -179,6 +181,7 @@ def test_create_file_update_version(self):
version_file_path = Path(VERSION_FILE_PATH)
content = version_file_path.read_text(encoding="utf-8")
self.assertIn(version, content)
version_file_path.unlink()


class ProjectFileGoVersionCommandTestCase(unittest.TestCase):
Expand Down

0 comments on commit aa0abb6

Please sign in to comment.