Skip to content

Commit

Permalink
Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
vd2org committed Feb 23, 2024
1 parent 5557820 commit fee56de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Yet another version bumper for your project.
I wanted to have a simple version bumper that I could use in my CI/CD pipeline.
I didn't want to have to install a bunch of dependencies or have to write a bunch of configs to just change the version number.

This tool having less than 400 lines of code and just one dependency (`tomlkit`) is the result of that.
This tool having less than 500 lines of code and just one dependency (`tomlkit`) is the result of that.

## What does it do?

Expand Down
14 changes: 6 additions & 8 deletions src/ubump/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def try_load(cls) -> tuple[ConfigMode, Self]:
raise BothConfigFoundError(f"Version config found in both files: {mode.pyproject} and {mode.ubump}!")

if not config and not pyproject:
raise ConfigNotFoundError(f"No version config found, use 'init' command to create one.")
raise ConfigNotFoundError(f"No version config found, use '{Action.init}' command to create one.")

return mode, config or pyproject

Expand Down Expand Up @@ -307,8 +307,7 @@ def bump(action: Action, version: Optional[str] = None, dry: bool = False):
mode, config = Config.try_load()

if not Git.is_repo_clean() and not dry:
logger.error(f"Git repo is not clean, aborting...")
return
raise ConfigError(f"Git repo is not clean, aborting...")

logger.info(f"Using version config from {mode}...")

Expand All @@ -327,10 +326,11 @@ def bump(action: Action, version: Optional[str] = None, dry: bool = False):
config.version = config.version._replace(minor=config.version.minor + 1, patch=0)
case Action.patch:
config.version = config.version._replace(patch=config.version.patch + 1)
case _:
raise RuntimeError(f"Unknown action: {action}")

if old_str_version == config.str_version:
logger.error(f"The version is already {config.str_version}, nothing to do.")
return
raise ConfigError(f"The version is already {config.str_version}, nothing to do.")

if not version:
logger.info(f"The new version is {config.str_version}...")
Expand All @@ -340,8 +340,7 @@ def bump(action: Action, version: Optional[str] = None, dry: bool = False):
nok = Tools.update_files(config, old_str_version, dry=True)

if nok:
logger.error(f"The current version is not found in some files, aborting...")
return
raise ConfigError(f"The current version is not found in some files, aborting...")

if not dry:
Tools.update_files(config, old_str_version)
Expand All @@ -356,7 +355,6 @@ def bump(action: Action, version: Optional[str] = None, dry: bool = False):

def main():
parser = ArgumentParser(prog=NAME, description="Minimalistic version bumper.")

parser.add_argument("--version", action="version", version=f"%(prog)s {VERSION}")

subs = parser.add_subparsers(title="Action", metavar="action", dest="action")
Expand Down

0 comments on commit fee56de

Please sign in to comment.