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

refactor(bump): add type for out, replace function with re escape #1429

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 2 additions & 6 deletions commitizen/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ def files_and_regexs(patterns: list[str], version: str) -> list[tuple[str, str]]
"""
Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
"""
out = []
out: list[tuple[str, str]] = []
for pattern in patterns:
drive, tail = os.path.splitdrive(pattern)
path, _, regex = tail.partition(":")
filepath = drive + path
if not regex:
regex = _version_to_regex(version)
regex = re.escape(version)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I understand this correctly. version is not a regex string right? And regex is just for substring matching?


for path in iglob(filepath):
out.append((path, regex))
Expand Down Expand Up @@ -138,10 +138,6 @@ def _bump_with_regex(
return current_version_found, "".join(lines)


def _version_to_regex(version: str) -> str:
return version.replace(".", r"\.").replace("+", r"\+")


def create_commit_message(
current_version: Version | str,
new_version: Version | str,
Expand Down