Skip to content

Commit 2090b7c

Browse files
committed
fix(changelog.py): modify the CHANGELOG.md generated by cz bump --changelog to the right place
1 parent 13bc11a commit 2090b7c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

commitizen/commands/changelog.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,28 @@ def __init__(self, config: BaseConfig, args):
3232
raise NotAGitProjectError()
3333

3434
self.config: BaseConfig = config
35-
self.encoding = self.config.settings["encoding"]
36-
self.cz = factory.commiter_factory(self.config)
37-
38-
self.start_rev = args.get("start_rev") or self.config.settings.get(
39-
"changelog_start_rev"
40-
)
41-
self.file_name = args.get("file_name") or cast(
35+
changelog_file_name = args.get("file_name") or cast(
4236
str, self.config.settings.get("changelog_file")
4337
)
44-
if not isinstance(self.file_name, str):
38+
if not isinstance(changelog_file_name, str):
4539
raise NotAllowed(
4640
"Changelog file name is broken.\n"
4741
"Check the flag `--file-name` in the terminal "
4842
f"or the setting `changelog_file` in {self.config.path}"
4943
)
44+
self.file_name = (
45+
str(Path(self.config.path.parent) / changelog_file_name)
46+
if self.config.path is not None
47+
else changelog_file_name
48+
)
49+
50+
self.encoding = self.config.settings["encoding"]
51+
self.cz = factory.commiter_factory(self.config)
52+
53+
self.start_rev = args.get("start_rev") or self.config.settings.get(
54+
"changelog_start_rev"
55+
)
56+
5057
self.changelog_format = get_changelog_format(self.config, self.file_name)
5158

5259
self.incremental = args["incremental"] or self.config.settings.get(

0 commit comments

Comments
 (0)