Skip to content

Commit d6b24f0

Browse files
committed
Add hooks configuration fields
Introduced `setup_hooks`, `pre_bump_hooks`, and `post_bump_hooks` fields to configuration models. Updated corresponding test fixtures to verify these new fields.
1 parent 304c599 commit d6b24f0

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

bumpversion/config/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"scm_info": None,
3535
"parts": {},
3636
"files": [],
37+
"setup_hooks": [],
38+
"pre_bump_hooks": [],
39+
"post_bump_hooks": [],
3740
}
3841

3942

bumpversion/config/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class Config(BaseSettings):
100100
scm_info: Optional["SCMInfo"]
101101
parts: Dict[str, VersionComponentSpec]
102102
files: List[FileChange] = Field(default_factory=list)
103+
setup_hooks: List[str] = Field(default_factory=list)
104+
pre_bump_hooks: List[str] = Field(default_factory=list)
105+
post_bump_hooks: List[str] = Field(default_factory=list)
103106
included_paths: List[str] = Field(default_factory=list)
104107
excluded_paths: List[str] = Field(default_factory=list)
105108
model_config = SettingsConfigDict(env_prefix="bumpversion_")

tests/fixtures/basic_cfg_expected.txt

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
'independent': False,
7979
'optional_value': 'gamma',
8080
'values': ['dev', 'gamma']}},
81+
'post_bump_hooks': [],
82+
'pre_bump_hooks': [],
8183
'regex': False,
8284
'replace': '{new_version}',
8385
'scm_info': {'branch_name': None,
@@ -91,6 +93,7 @@
9193
'tool': None},
9294
'search': '{current_version}',
9395
'serialize': ('{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}'),
96+
'setup_hooks': [],
9497
'sign_tags': False,
9598
'tag': True,
9699
'tag_message': 'Bump version: {current_version} → {new_version}',

tests/fixtures/basic_cfg_expected.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ parts:
106106
values:
107107
- "dev"
108108
- "gamma"
109+
post_bump_hooks:
110+
111+
pre_bump_hooks:
112+
109113
regex: false
110114
replace: "{new_version}"
111115
scm_info:
@@ -122,6 +126,8 @@ search: "{current_version}"
122126
serialize:
123127
- "{major}.{minor}.{patch}-{release}"
124128
- "{major}.{minor}.{patch}"
129+
setup_hooks:
130+
125131
sign_tags: false
126132
tag: true
127133
tag_message: "Bump version: {current_version} → {new_version}"

tests/fixtures/basic_cfg_expected_full.json

+3
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
]
122122
}
123123
},
124+
"post_bump_hooks": [],
125+
"pre_bump_hooks": [],
124126
"regex": false,
125127
"replace": "{new_version}",
126128
"scm_info": {
@@ -139,6 +141,7 @@
139141
"{major}.{minor}.{patch}-{release}",
140142
"{major}.{minor}.{patch}"
141143
],
144+
"setup_hooks": [],
142145
"sign_tags": false,
143146
"tag": true,
144147
"tag_message": "Bump version: {current_version} \u2192 {new_version}",

0 commit comments

Comments
 (0)