@@ -66,9 +66,8 @@ def __init__(self, config: BaseConfig, arguments: dict):
66
66
},
67
67
}
68
68
self .cz = factory .commiter_factory (self .config )
69
- self .changelog = arguments ["changelog" ] or self .config .settings .get (
70
- "update_changelog_on_bump"
71
- )
69
+ self .changelog_flag = arguments ["changelog" ]
70
+ self .changelog_config = self .config .settings .get ("update_changelog_on_bump" )
72
71
self .changelog_to_stdout = arguments ["changelog_to_stdout" ]
73
72
self .git_output_to_stderr = arguments ["git_output_to_stderr" ]
74
73
self .no_verify = arguments ["no_verify" ]
@@ -207,17 +206,24 @@ def __call__(self) -> None: # noqa: C901
207
206
"--local-version cannot be combined with --build-metadata"
208
207
)
209
208
210
- # If user specified changelog_to_stdout, they probably want the
211
- # changelog to be generated as well, this is the most intuitive solution
212
- self .changelog = self .changelog or bool (self .changelog_to_stdout )
213
-
214
209
if get_next :
215
- if self .changelog :
210
+ # if trying to use --get-next, we should not allow --changelog or --changelog-to-stdout
211
+ if self .changelog_flag or bool (self .changelog_to_stdout ):
216
212
raise NotAllowed (
217
213
"--changelog or --changelog-to-stdout is not allowed with --get-next"
218
214
)
215
+ # --get-next is a special case, taking precedence over config for 'update_changelog_on_bump'
216
+ self .changelog_config = False
219
217
# Setting dry_run to prevent any unwanted changes to the repo or files
220
218
self .dry_run = True
219
+ else :
220
+ # If user specified changelog_to_stdout, they probably want the
221
+ # changelog to be generated as well, this is the most intuitive solution
222
+ self .changelog_flag = (
223
+ self .changelog_flag
224
+ or bool (self .changelog_to_stdout )
225
+ or self .changelog_config
226
+ )
221
227
222
228
current_tag_version : str = bump .normalize_tag (
223
229
current_version ,
@@ -309,7 +315,7 @@ def __call__(self) -> None: # noqa: C901
309
315
)
310
316
311
317
files : list [str ] = []
312
- if self .changelog :
318
+ if self .changelog_flag :
313
319
args = {
314
320
"unreleased_version" : new_tag_version ,
315
321
"template" : self .template ,
@@ -356,7 +362,9 @@ def __call__(self) -> None: # noqa: C901
356
362
new_tag_version = new_tag_version ,
357
363
message = message ,
358
364
increment = increment ,
359
- changelog_file_name = changelog_cmd .file_name if self .changelog else None ,
365
+ changelog_file_name = changelog_cmd .file_name
366
+ if self .changelog_flag
367
+ else None ,
360
368
)
361
369
362
370
if is_files_only :
@@ -365,7 +373,7 @@ def __call__(self) -> None: # noqa: C901
365
373
# FIXME: check if any changes have been staged
366
374
git .add (* files )
367
375
c = git .commit (message , args = self ._get_commit_args ())
368
- if self .retry and c .return_code != 0 and self .changelog :
376
+ if self .retry and c .return_code != 0 and self .changelog_flag :
369
377
# Maybe pre-commit reformatted some files? Retry once
370
378
logger .debug ("1st git.commit error: %s" , c .err )
371
379
logger .info ("1st commit attempt failed; retrying once" )
@@ -410,7 +418,9 @@ def __call__(self) -> None: # noqa: C901
410
418
current_tag_version = new_tag_version ,
411
419
message = message ,
412
420
increment = increment ,
413
- changelog_file_name = changelog_cmd .file_name if self .changelog else None ,
421
+ changelog_file_name = changelog_cmd .file_name
422
+ if self .changelog_flag
423
+ else None ,
414
424
)
415
425
416
426
# TODO: For v3 output this only as diagnostic and remove this if
0 commit comments