Skip to content

Commit

Permalink
fix(history): coerce version to string (#298)
Browse files Browse the repository at this point in the history
The changes in #297 mistakenly omitted coercing the return value to a
string. This resulted in errors like:
"can only concatenate str (not "VersionInfo") to str"

Add test case asserting it's type str
  • Loading branch information
wyardley authored Dec 21, 2020
1 parent 5087e54 commit d4cdc3d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion semantic_release/history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def get_new_version(current_version: str, level_bump: str) -> str:
if not level_bump:
logger.debug("No bump requested, returning input version")
return current_version
return semver.VersionInfo.parse(current_version).next_version(part=level_bump)
return str(semver.VersionInfo.parse(current_version).next_version(part=level_bump))


@LoggedFunction(logger)
Expand Down
1 change: 1 addition & 0 deletions tests/history/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_major_bump(self):
assert get_new_version("10.1.0", "major") == "11.0.0"

def test_minor_bump(self):
assert type(get_new_version("0.0.0", "minor")) is str
assert get_new_version("0.0.0", "minor") == "0.1.0"
assert get_new_version("1.2.0", "minor") == "1.3.0"
assert get_new_version("1.2.1", "minor") == "1.3.0"
Expand Down

0 comments on commit d4cdc3d

Please sign in to comment.