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

perf(bump): avoid unnecessary list construction and rename variable t… #1504

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 1 commit into from
Jun 8, 2025
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
14 changes: 8 additions & 6 deletions commitizen/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
from collections import OrderedDict
from collections.abc import Iterable
from glob import iglob
from logging import getLogger
from string import Template
Expand Down Expand Up @@ -61,7 +62,7 @@ def find_increment(
def update_version_in_files(
current_version: str,
new_version: str,
files: list[str],
files: Iterable[str],
*,
check_consistency: bool = False,
encoding: str = ENCODING,
Expand Down Expand Up @@ -99,21 +100,22 @@ def update_version_in_files(
return updated


def _files_and_regexes(patterns: list[str], version: str) -> list[tuple[str, str]]:
def _files_and_regexes(patterns: Iterable[str], version: str) -> list[tuple[str, str]]:
"""
Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
"""
out: list[tuple[str, str]] = []
out: set[tuple[str, str]] = set()
for pattern in patterns:
drive, tail = os.path.splitdrive(pattern)
path, _, regex = tail.partition(":")
filepath = drive + path
if not regex:
regex = re.escape(version)

for path in iglob(filepath):
out.append((path, regex))
return sorted(list(set(out)))
for file in iglob(filepath):
out.add((file, regex))

return sorted(out)


def _bump_with_regex(
Expand Down