Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 99b4faa

Browse filesBrowse files
Yusin0903Lee-W
authored andcommitted
fix(changelog.py): cross-platform path handling using os.path.join and modify the path linter and test parameter
1 parent 6067dc9 commit 99b4faa
Copy full SHA for 99b4faa

File tree

2 files changed

+10
-4
lines changed
Filter options

2 files changed

+10
-4
lines changed

‎commitizen/commands/changelog.py

Copy file name to clipboardExpand all lines: commitizen/commands/changelog.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import os.path
45
from difflib import SequenceMatcher
56
from operator import itemgetter
@@ -42,7 +43,7 @@ def __init__(self, config: BaseConfig, args):
4243
f"or the setting `changelog_file` in {self.config.path}"
4344
)
4445
self.file_name = (
45-
str(Path(self.config.path.parent) / changelog_file_name)
46+
os.path.join(str(self.config.path.parent), changelog_file_name)
4647
if self.config.path is not None
4748
else changelog_file_name
4849
)

‎tests/test_changelog.py

Copy file name to clipboardExpand all lines: tests/test_changelog.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import re
23
from dataclasses import dataclass
34
from pathlib import Path
@@ -1638,7 +1639,7 @@ def test_tags_rules_get_version_tags(capsys: pytest.CaptureFixture):
16381639

16391640
def test_changelog_file_name_from_args_and_config():
16401641
mock_config = Mock(spec=BaseConfig)
1641-
mock_config.path.parent = "/my/project/"
1642+
mock_config.path.parent = "/my/project"
16421643
mock_config.settings = {
16431644
"name": "cz_conventional_commits",
16441645
"changelog_file": "CHANGELOG.md",
@@ -1658,8 +1659,12 @@ def test_changelog_file_name_from_args_and_config():
16581659
"unreleased_version": "1.0.1",
16591660
}
16601661
changelog = Changelog(mock_config, args)
1661-
assert changelog.file_name == "/my/project/CUSTOM.md"
1662+
assert os.path.normpath(changelog.file_name) == os.path.normpath(
1663+
os.path.join("/my/project", "CUSTOM.md")
1664+
)
16621665

16631666
args = {"incremental": None, "dry_run": False, "unreleased_version": "1.0.1"}
16641667
changelog = Changelog(mock_config, args)
1665-
assert changelog.file_name == "/my/project/CHANGELOG.md"
1668+
assert os.path.normpath(changelog.file_name) == os.path.normpath(
1669+
os.path.join("/my/project", "CHANGELOG.md")
1670+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.