(self)
| 190 | Path(dist).write_text(text) |
| 191 | |
| 192 | def __call__(self) -> None: |
| 193 | commit_parser = self.cz.commit_parser |
| 194 | changelog_pattern = self.cz.changelog_pattern |
| 195 | start_rev = self.start_rev |
| 196 | |
| 197 | if self.export_template_to: |
| 198 | return self._export_template(self.export_template_to) |
| 199 | |
| 200 | if not changelog_pattern or not commit_parser: |
| 201 | raise NoPatternMapError( |
| 202 | f"'{self.config.settings['name']}' rule does not support changelog" |
| 203 | ) |
| 204 | |
| 205 | if self.incremental and self.rev_range: |
| 206 | raise NotAllowed("--incremental cannot be combined with a rev_range") |
| 207 | |
| 208 | # Don't continue if no `file_name` specified. |
| 209 | if not self.file_name: |
| 210 | raise NotAllowed("filename is required.") |
| 211 | |
| 212 | tags = self.tag_rules.get_version_tags(git.get_tags(), warn=True) |
| 213 | changelog_meta = changelog.Metadata() |
| 214 | if self.incremental: |
| 215 | changelog_meta = self.changelog_format.get_metadata(self.file_name) |
| 216 | if changelog_meta.latest_version: |
| 217 | start_rev = self._find_incremental_rev( |
| 218 | strip_local_version(changelog_meta.latest_version_tag or ""), tags |
| 219 | ) |
| 220 | |
| 221 | end_rev = "" |
| 222 | if self.rev_range: |
| 223 | start_rev, end_rev = changelog.get_oldest_and_newest_rev( |
| 224 | tags, |
| 225 | self.rev_range, |
| 226 | self.tag_rules, |
| 227 | ) |
| 228 | |
| 229 | if self.during_version_bump and self.tag_rules.merge_prereleases: |
| 230 | latest_full_release_info = self.changelog_format.get_latest_full_release( |
| 231 | self.file_name |
| 232 | ) |
| 233 | # Determine if there are prereleases to merge: |
| 234 | # - Only prereleases in changelog (no full release found), OR |
| 235 | # - First version in changelog is before first full release (prereleases exist) |
| 236 | if latest_full_release_info.index is not None and ( |
| 237 | latest_full_release_info.name is None |
| 238 | or ( |
| 239 | changelog_meta.latest_version_position is not None |
| 240 | and changelog_meta.latest_version_position |
| 241 | < latest_full_release_info.index |
| 242 | ) |
| 243 | ): |
| 244 | # Use the existing unreleased_start if available (from get_metadata()). |
| 245 | # Otherwise, use the position of the first version entry (prerelease) |
| 246 | # to preserve the changelog header. |
| 247 | if changelog_meta.unreleased_start is None: |
| 248 | changelog_meta.unreleased_start = ( |
| 249 | changelog_meta.latest_version_position |
nothing calls this directly
no test coverage detected