Skip to content

Commit 9d2fcbe

Browse files
authored
Merge pull request #155 from callowayproject/fix-legacy-multiline
Fix legacy multiline
2 parents 5e4d9a4 + c40e4f9 commit 9d2fcbe

File tree

6 files changed

+53
-3
lines changed

6 files changed

+53
-3
lines changed

.github/workflows/version.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ on:
33
pull_request:
44
types: [closed]
55
branches: [master]
6+
workflow_dispatch:
7+
inputs:
8+
releaseType:
9+
description: 'What kind of release is this?'
10+
required: false
11+
default: 'auto'
12+
type: choice
13+
options:
14+
- 'auto'
15+
- 'major'
16+
- 'minor'
17+
- 'patch'
18+
- 'dev'
619

720
jobs:
821
version:
@@ -36,6 +49,14 @@ jobs:
3649
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
3750
echo "PACKAGE=false" >> $GITHUB_ENV
3851
52+
- name: Override release kind on manual
53+
if: ${{ github.event.inputs.releaseType != 'auto' }}
54+
id: override-release-kind
55+
run: |
56+
echo "::notice::Overriding release type to ${{ github.event.inputs.releaseType }} since this was a manual trigger"
57+
echo "RELEASE_KIND=${{ github.event.inputs.releaseType }}" >> $GITHUB_ENV
58+
echo "release-kind=${{ github.event.inputs.releaseType }}" >> $GITHUB_OUTPUT
59+
3960
- name: Get Pull Request Number
4061
id: pr
4162
run: |
@@ -59,7 +80,7 @@ jobs:
5980
echo "PACKAGE=true" >> $GITHUB_ENV
6081
;;
6182
dev)
62-
echo "Intentionally not bumping version for dev release"
83+
bump-my-version bump --allow-dirty --verbose --no-commit --no-tag "$RELEASE_KIND"
6384
;;
6485
esac
6586

bumpversion/autocast.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ def listify(s: str) -> list:
4343
Returns:
4444
List of homogenous basic types.
4545
"""
46-
if "," not in s and "\n" not in s:
46+
if "\n" in s:
47+
str_list = s.strip().split("\n")
48+
elif "," in s:
49+
str_list = s.strip().split(",")
50+
else:
4751
raise ValueError("Not a List")
4852

4953
# derive the type of the variable
50-
str_list = s.strip().split(",") if "," in s else s.strip().split("\n")
5154
element_caster = str
5255
for caster in (boolify, int, float, noneify, element_caster):
5356
with contextlib.suppress(ValueError):
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bumpversion]
2+
current_version = 1.0.0
3+
4+
[bumpversion:file:MULTILINE_SEARCH.md]
5+
search = **unreleased**,
6+
**v{current_version}**,
7+
replace = **unreleased**,
8+
**v{new_version}**,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"current_version": "1.0.0",
3+
"files": [
4+
{
5+
"filename": "MULTILINE_SEARCH.md",
6+
"search": "**unreleased**,\n**v{current_version}**,",
7+
"replace": "**unreleased**,\n**v{new_version}**,"
8+
}
9+
],
10+
"parts": {}
11+
}

tests/test_autocast.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_noneify():
4646
param("1,2,3,4", [1, 2, 3, 4], id="int"),
4747
param("1\n2\n3\n4", [1, 2, 3, 4], id="int"),
4848
param("s,t,r", ["s", "t", "r"], id="str"),
49+
param("s,\nt,\nr\n", ["s,", "t,", "r"], id="str_newline"),
4950
param("1.1,2,3.14", [1.1, 2.0, 3.14], id="float"),
5051
param("True,False,true,false", [True, False, True, False], id="bool"),
5152
param("None,None,None", [None, None, None], id="none"),
@@ -75,6 +76,7 @@ def test_listify_invalid():
7576
param("False", False, id="False"),
7677
param("1,2,3,4", [1, 2, 3, 4], id="int-list"),
7778
param("s,t,r", ["s", "t", "r"], id="str-list"),
79+
param("s,\nt,\nr\n", ["s,", "t,", "r"], id="str-list-newline"),
7880
param("1", 1, id="int"),
7981
param("1.0", 1.0, id="float"),
8082
param(1, 1, id="real-int"),

tests/test_config/test_files_legacy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def cfg_file(request) -> str:
3535
[
3636
param("basic_cfg.cfg", "basic_cfg_expected.json", id="ini basic cfg"),
3737
param("legacy_multiline_search.cfg", "legacy_multiline_search_expected.json", id="multiline search cfg"),
38+
param(
39+
"legacy_multiline_search_comma.cfg",
40+
"legacy_multiline_search_comma_expected.json",
41+
id="multiline search comma cfg",
42+
),
3843
],
3944
)
4045
def test_read_ini_file(conf_file: str, expected_file: str, fixtures_path: Path) -> None:

0 commit comments

Comments
 (0)