Skip to content

Commit

Permalink
Change: Include changes from pre-releases in non pre-releases
Browse files Browse the repository at this point in the history
Ignore pre-releases when determining the last release version if a non
pre-release is created. This includes all the changes of the previous
pre-releases into the changelog.

But still consider pre-releases when determining the last release when
a release series is used. Otherwise we might not determine a last
release when there are only pre-releases in the release series yet.
  • Loading branch information
bjoernricks committed Jan 12, 2024
1 parent 84ecc39 commit c725fce
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pontos/release/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ async def async_run( # type: ignore[override]
tag_name=f"{self.git_tag_prefix}{release_series}.*"
if release_series
else None,
# include changes from pre-releases in release changelog for
# non pre-release changes
ignore_pre_releases=release_type
not in [
ReleaseType.ALPHA,
ReleaseType.BETA,
ReleaseType.RELEASE_CANDIDATE,
]
# but not when using a release series because then we might not
# be able to determine the last release if there are only
# pre-releases in the series yet
and not release_series,
)
except PontosError as e:
last_release_version = None
Expand Down
55 changes: 54 additions & 1 deletion tests/release/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ def test_release_patch(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=True,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -517,6 +524,13 @@ def test_release_calendar(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=True,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -625,6 +639,13 @@ def test_release_minor(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=True,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -730,6 +751,13 @@ def test_release_major(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=True,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -833,6 +861,13 @@ def test_release_alpha(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=False,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -938,6 +973,13 @@ def test_release_beta(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=False,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -1043,6 +1085,13 @@ def test_release_release_candidate(
token=token, # type: ignore[arg-type]
)

get_last_release_version_mock.assert_called_once_with(
parse_version=PEP440VersioningScheme.parse_version,
git_tag_prefix="v",
tag_name=None,
ignore_pre_releases=False,
)

git_instance_mock.push.assert_has_calls(
[
call(follow_tags=True, remote=None),
Expand Down Expand Up @@ -2715,7 +2764,11 @@ def test_release_series(
token=token, # type: ignore[arg-type]
)

self.assertEqual(released, CreateReleaseReturnValue.SUCCESS)
self.assertEqual(
released,
CreateReleaseReturnValue.SUCCESS,
f"Invalid return value for {r}",
)
self.assertEqual(
create_api_mock.call_args.args[1],
f"v{r.expected_release_version}",
Expand Down

0 comments on commit c725fce

Please sign in to comment.