Skip to content

fix(cmd-version): fix handling of multiple prerelease token variants & git flow merges #1120

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
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions src/semantic_release/cli/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from semantic_release.cli.config import GlobalCommandLineOptions
from semantic_release.cli.const import DEFAULT_CONFIG_FILE
from semantic_release.cli.util import rprint
from semantic_release.enums import SemanticReleaseLogLevels

# if TYPE_CHECKING:
# pass
Expand Down Expand Up @@ -108,7 +109,15 @@ def main(
"""
console = Console(stderr=True)

log_level = [logging.WARNING, logging.INFO, logging.DEBUG][verbosity]
log_levels = [
SemanticReleaseLogLevels.WARNING,
SemanticReleaseLogLevels.INFO,
SemanticReleaseLogLevels.DEBUG,
SemanticReleaseLogLevels.SILLY,
]

log_level = log_levels[verbosity]

logging.basicConfig(
level=log_level,
format=FORMAT,
Expand All @@ -123,7 +132,7 @@ def main(
logger = logging.getLogger(__name__)
logger.debug("logging level set to: %s", logging.getLevelName(log_level))

if log_level == logging.DEBUG:
if log_level <= logging.DEBUG:
globals.debug = True

if noop:
Expand Down
30 changes: 30 additions & 0 deletions src/semantic_release/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import logging
from enum import IntEnum, unique


Expand Down Expand Up @@ -37,3 +38,32 @@ def from_string(cls, val: str) -> LevelBump:
>>> LevelBump.from_string("minor") == LevelBump.MINOR
"""
return cls[val.upper().replace("-", "_")]


class SemanticReleaseLogLevels(IntEnum):
"""IntEnum representing the log levels used by semantic-release."""

FATAL = logging.FATAL
CRITICAL = logging.CRITICAL
ERROR = logging.ERROR
WARNING = logging.WARNING
INFO = logging.INFO
DEBUG = logging.DEBUG
SILLY = 5

def __str__(self) -> str:
"""
Return the level name rather than 'SemanticReleaseLogLevels.<level>'
E.g.
>>> str(SemanticReleaseLogLevels.DEBUG)
'DEBUG'
>>> str(SemanticReleaseLogLevels.CRITICAL)
'CRITICAL'
"""
return self.name.upper()


logging.addLevelName(
SemanticReleaseLogLevels.SILLY,
str(SemanticReleaseLogLevels.SILLY),
)
Loading
Loading