Skip to content

Commit 23a9e38

Browse files
committed
refactor(changelog): rename variables and remove commit_tag
1 parent 1ae2d12 commit 23a9e38

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

commitizen/changelog.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ def get_commit_tag(commit: GitCommit, tags: list[GitTag]) -> GitTag | None:
7575

7676

7777
def _get_release_info(
78-
current_tag_name: str,
79-
current_tag_date: str,
78+
prev_tag_name: str,
79+
prev_tag_date: str,
8080
changes: dict[str | None, list],
8181
changelog_release_hook: ChangelogReleaseHook | None,
8282
commit_tag: GitTag | None,
8383
) -> dict[str, Any]:
8484
release = {
85-
"version": current_tag_name,
86-
"date": current_tag_date,
85+
"version": prev_tag_name,
86+
"date": prev_tag_date,
8787
"changes": changes,
8888
}
8989
if changelog_release_hook:
@@ -108,41 +108,38 @@ def generate_tree_from_commits(
108108
rules = rules or TagRules()
109109

110110
used_tags: set[GitTag] = set()
111-
current_tag_name = unreleased_version or "Unreleased"
112-
current_tag_date = (
113-
date.today().isoformat() if unreleased_version is not None else ""
114-
)
111+
prev_tag_name = unreleased_version or "Unreleased"
112+
prev_tag_date = date.today().isoformat() if unreleased_version is not None else ""
115113

116114
# Check if the latest commit is not tagged
117115
current_tag = get_commit_tag(commits[0], tags) if commits else None
118116
if current_tag is not None:
119117
used_tags.add(current_tag)
120118
if current_tag.name:
121-
current_tag_name = current_tag.name
122-
current_tag_date = current_tag.date
119+
prev_tag_name = current_tag.name
120+
prev_tag_date = current_tag.date
123121

124122
changes: defaultdict[str | None, list] = defaultdict(list)
125-
commit_tag: GitTag | None = None
126123
for commit in commits:
127-
commit_tag = get_commit_tag(commit, tags)
124+
current_tag = get_commit_tag(commit, tags)
128125

129126
if (
130-
commit_tag
131-
and commit_tag not in used_tags
132-
and rules.include_in_changelog(commit_tag)
127+
current_tag
128+
and current_tag not in used_tags
129+
and rules.include_in_changelog(current_tag)
133130
):
134-
used_tags.add(commit_tag)
131+
used_tags.add(current_tag)
135132

136133
yield _get_release_info(
137-
current_tag_name,
138-
current_tag_date,
134+
prev_tag_name,
135+
prev_tag_date,
139136
changes,
140137
changelog_release_hook,
141-
commit_tag,
138+
current_tag,
142139
)
143140

144-
current_tag_name = commit_tag.name
145-
current_tag_date = commit_tag.date
141+
prev_tag_name = current_tag.name
142+
prev_tag_date = current_tag.date
146143
changes = defaultdict(list)
147144

148145
if not pat.match(commit.message):
@@ -171,11 +168,11 @@ def generate_tree_from_commits(
171168
)
172169

173170
yield _get_release_info(
174-
current_tag_name,
175-
current_tag_date,
171+
prev_tag_name,
172+
prev_tag_date,
176173
changes,
177174
changelog_release_hook,
178-
commit_tag,
175+
current_tag,
179176
)
180177

181178

0 commit comments

Comments
 (0)