mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 22:40:09 +01:00
improve test coverage
This commit is contained in:
parent
d23689634c
commit
6b1a3e45d3
8 changed files with 118 additions and 162 deletions
|
|
@ -303,19 +303,24 @@ def show(verbose: int = 0, fetch: bool = True) -> None:
|
|||
click.echo(f"PEP440 : {cfg.pep440_version}")
|
||||
|
||||
|
||||
def _colored_diff_lines(diff: str) -> typ.Iterable[str]:
|
||||
for line in diff.splitlines():
|
||||
if line.startswith("+++") or line.startswith("---"):
|
||||
yield line
|
||||
elif line.startswith("+"):
|
||||
yield "\u001b[32m" + line + "\u001b[0m"
|
||||
elif line.startswith("-"):
|
||||
yield "\u001b[31m" + line + "\u001b[0m"
|
||||
elif line.startswith("@"):
|
||||
yield "\u001b[36m" + line + "\u001b[0m"
|
||||
else:
|
||||
yield line
|
||||
|
||||
|
||||
def _print_diff_str(diff: str) -> None:
|
||||
colored_diff = "\n".join(_colored_diff_lines(diff))
|
||||
if sys.stdout.isatty():
|
||||
for line in diff.splitlines():
|
||||
if line.startswith("+++") or line.startswith("---"):
|
||||
click.echo(line)
|
||||
elif line.startswith("+"):
|
||||
click.echo("\u001b[32m" + line + "\u001b[0m")
|
||||
elif line.startswith("-"):
|
||||
click.echo("\u001b[31m" + line + "\u001b[0m")
|
||||
elif line.startswith("@"):
|
||||
click.echo("\u001b[36m" + line + "\u001b[0m")
|
||||
else:
|
||||
click.echo(line)
|
||||
click.echo(colored_diff)
|
||||
else:
|
||||
click.echo(diff)
|
||||
|
||||
|
|
@ -331,11 +336,6 @@ def _print_diff(cfg: config.Config, new_version: str) -> None:
|
|||
except rewrite.NoPatternMatch as ex:
|
||||
logger.error(str(ex))
|
||||
sys.exit(1)
|
||||
except Exception as ex:
|
||||
# pylint:disable=broad-except; Mostly we expect IOError here, but
|
||||
# could be other things and there's no option to recover anyway.
|
||||
logger.error(str(ex), exc_info=True)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def incr_dispatch(
|
||||
|
|
@ -417,10 +417,6 @@ def _bump(
|
|||
except rewrite.NoPatternMatch as ex:
|
||||
logger.error(str(ex))
|
||||
sys.exit(1)
|
||||
except Exception as ex:
|
||||
# TODO (mb 2020-09-18): Investigate error messages
|
||||
logger.error(str(ex))
|
||||
sys.exit(1)
|
||||
|
||||
if vcs_api:
|
||||
vcs.commit(cfg, vcs_api, filepaths, new_version, commit_message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue