Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix(Changelog): fix _export_template variable type #1550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions commitizen/commands/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,15 @@

changelog_file.write(changelog_out)

def _export_template(self) -> None:
tpl = changelog.get_changelog_template(self.cz.template_loader, self.template)
# TODO: fix the following type ignores
src = Path(tpl.filename) # type: ignore[arg-type]
Path(self.export_template_to).write_text(src.read_text()) # type: ignore[arg-type]
def _export_template(self, dist: str) -> None:
filename = changelog.get_changelog_template(
self.cz.template_loader, self.template
).filename
if filename is None:
raise NotAllowed("Template filename is not set")

Check warning on line 182 in commitizen/commands/changelog.py

View check run for this annotation

Codecov / codecov/patch

commitizen/commands/changelog.py#L182

Added line #L182 was not covered by tests

text = Path(filename).read_text()
Path(dist).write_text(text)

def __call__(self) -> None:
commit_parser = self.cz.commit_parser
Expand All @@ -195,7 +199,7 @@
)

if self.export_template_to:
return self._export_template()
return self._export_template(self.export_template_to)

if not changelog_pattern or not commit_parser:
raise NoPatternMapError(
Expand Down