Skip to content

Commit

Permalink
Fix skip_future_releases option
Browse files Browse the repository at this point in the history
Fixes #3594

As written, skip_future_releases is always `True` for
`skip_future_releases: False` or `skip_future_releases: false` because
those get converted to booleans before being passed to
`process_bool_arg`. This was working as designed when run through the
CLI because the option doesn't go through the Pydantic model so it's a
`str`.
  • Loading branch information
jstvz committed Jul 17, 2023
1 parent e5e9d8b commit 3b276b8
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cumulusci/tasks/github/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ def _init_options(self, kwargs):
self.options[
"source_branch"
] = self.project_config.project__git__default_branch
self.options["skip_future_releases"] = process_bool_arg(
self.options.get("skip_future_releases") or True
)
if "skip_future_releases" not in self.options:
self.options["skip_future_releases"] = True
else:
self.options["skip_future_releases"] = process_bool_arg(
self.options.get("skip_future_releases")
)
self.options["update_future_releases"] = process_bool_arg(
self.options.get("update_future_releases") or False
)
Expand Down
106 changes: 105 additions & 1 deletion cumulusci/tasks/github/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,13 @@ def test_branches_to_merge__feature_merge_no_children(self):
def test_merge_to_future_release_branches(self):
"""Tests that commits to the main branch are merged to the expected feature branches"""
self._setup_mocks(
["main", "feature/230", "feature/232", "feature/300", "feature/work-item"]
[
"main",
"feature/230",
"feature/232",
"feature/300",
"feature/work-item",
]
)

task = self._create_task(
Expand All @@ -660,6 +666,104 @@ def test_merge_to_future_release_branches(self):
assert ["feature/232", "feature/300"] == actual_branches
assert 2 == len(responses.calls)

@responses.activate
def test_merge_to_future_release_branches_skip(self):
"""Tests that commits to the main branch are merged to the expected feature branches"""
self._setup_mocks(
[
"main",
"feature/230",
"feature/232",
"feature/300",
"feature/302",
"feature/work-item",
]
)

task = self._create_task(
task_config={
"options": {
"source_branch": "feature/230",
"branch_prefix": "feature/",
"update_future_releases": False,
}
}
)
task._init_task()

actual_branches = [branch.name for branch in task._get_branches_to_merge()]

assert [] == actual_branches
assert 2 == len(responses.calls)

@responses.activate
def test_merge_to_future_release_branches_skip_future(self):
"""
Tests that commits are not merged to "release" (numeric) branches
"""

self._setup_mocks(
[
"main",
"feature/230",
"feature/232",
"feature/300",
"feature/work-item",
]
)

task = self._create_task(
task_config={
"options": {
"source_branch": "main",
"branch_prefix": "feature/",
"update_future_releases": False,
"skip_future_releases": True,
}
}
)
task._init_task()

actual_branches = [branch.name for branch in task._get_branches_to_merge()]

assert ["feature/230", "feature/work-item"] == actual_branches
assert 2 == len(responses.calls)

@responses.activate
def test_merge_to_future_release_branches_noskip_future(self):
"""Tests that commits to the main branch are merged to the expected feature branches"""
self._setup_mocks(
[
"main",
"feature/230",
"feature/232",
"feature/300",
"feature/work-item",
]
)

task = self._create_task(
task_config={
"options": {
"source_branch": "main",
"branch_prefix": "feature/",
"update_future_releases": False,
"skip_future_releases": False,
}
}
)
task._init_task()

actual_branches = [branch.name for branch in task._get_branches_to_merge()]

assert [
"feature/230",
"feature/232",
"feature/300",
"feature/work-item",
] == actual_branches
assert 2 == len(responses.calls)

@responses.activate
def test_merge_to_future_release_branches_missing_slash(self):
"""Tests that commits to the main branch are merged to the expected feature branches"""
Expand Down

0 comments on commit 3b276b8

Please sign in to comment.