Skip to content

perf(cmd-version): re-order operations for faster parsing in version determination #1310

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
23 changes: 5 additions & 18 deletions src/semantic_release/version/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,7 @@ def next_version(
# Step 5. apply the parser to each commit in the history (could return multiple results per commit)
parsed_results = list(map(commit_parser.parse, commits_since_last_release))

# Step 5A. Validation type check for the parser results (important because of possible custom parsers)
for parsed_result in parsed_results:
if not any(
(
isinstance(parsed_result, (ParseError, ParsedCommit)),
type(parsed_result) == list
and validate_types_in_sequence(
parsed_result, (ParseError, ParsedCommit)
),
type(parsed_result) == tuple
and validate_types_in_sequence(
parsed_result, (ParseError, ParsedCommit)
),
)
):
raise TypeError("Unexpected type returned from commit_parser.parse")

# Step 5B. Accumulate all parsed results into a single list accounting for possible multiple results per commit
# Step 5A. Accumulate all parsed results into a single list accounting for possible multiple results per commit
consolidated_results: list[ParseResult] = reduce(
lambda accumulated_results, p_results: [
*accumulated_results,
Expand All @@ -378,6 +361,10 @@ def next_version(
[],
)

# Step 5B. Validation type check for the parser results (important because of possible custom parsers)
if not validate_types_in_sequence(consolidated_results, (ParseError, ParsedCommit)):
raise TypeError("Unexpected type returned from commit_parser.parse")

# Step 5C. Parse the commits to determine the bump level that should be applied
parsed_levels: set[LevelBump] = {
parsed_result.bump # type: ignore[union-attr] # too complex for type checkers
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy