Skip to content

Commit

Permalink
error if new version == current version
Browse files Browse the repository at this point in the history
  • Loading branch information
slashformotion committed Feb 25, 2024
1 parent 682aef6 commit a521e2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tbump/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ def run_bump(
bump(bump_options, _construct_operations(arguments))


class NotANewVersion(Error):
def __init__(self):
super().__init__()

def print_error(self) -> None:
ui.error("New version is the same as the previous one")


def bump(options: BumpOptions, operations: List[str]) -> None:
working_path = options.working_path
new_version = options.new_version
Expand All @@ -220,6 +228,9 @@ def bump(options: BumpOptions, operations: List[str]) -> None:
)
config = config_file.get_config()

if config.current_version == new_version:
raise NotANewVersion()

# fmt: off
ui.info_1(
"Bumping from", ui.bold, config.current_version,
Expand Down
3 changes: 2 additions & 1 deletion tbump/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import tomlkit

from tbump.cli import run as run_tbump
from tbump.cli import NotANewVersion
from tbump.config import ConfigNotFound, InvalidConfig
from tbump.error import Error
from tbump.file_bumper import (
Expand Down Expand Up @@ -317,7 +318,7 @@ def test_abort_if_file_does_not_contain_current_version(test_repo: Path) -> None
def test_no_tracked_branch_but_ref_exists(test_repo: Path) -> None:
run_git(test_repo, "checkout", "-b", "devel")

with pytest.raises(RefAlreadyExists):
with pytest.raises(NotANewVersion):
run_tbump(["-C", str(test_repo), "1.2.41-alpha-1"])


Expand Down

0 comments on commit a521e2e

Please sign in to comment.