fix gitlab.com #5: better bump warning for semver

This commit is contained in:
Manuel Barkhau 2019-07-09 10:07:26 +02:00
parent a3d1a559b8
commit e743359881
3 changed files with 75 additions and 8 deletions

View file

@ -354,7 +354,12 @@ def bump(
patch=patch,
)
if new_version is None:
log.error(f"Invalid version '{old_version}' and/or pattern '{cfg.version_pattern}'.")
is_semver = "{semver}" in cfg.version_pattern
has_semver_inc = major or minor or patch
if is_semver and not has_semver_inc:
log.warning("bump --major/--minor/--patch required when using semver.")
else:
log.error(f"Invalid version '{old_version}' and/or pattern '{cfg.version_pattern}'.")
sys.exit(1)
log.info(f"Old Version: {old_version}")

View file

@ -472,6 +472,9 @@ def write_content(ctx: ProjectContext) -> None:
fh: typ.IO[str]
cfg_content = default_config(ctx)
if ctx.config_filepath.exists():
cfg_content = "\n" + cfg_content
with ctx.config_filepath.open(mode="at", encoding="utf-8") as fh:
fh.write(cfg_content)
print(f"Updated {ctx.config_filepath}")