mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
add coloured output for --dry
This commit is contained in:
parent
548fb871e0
commit
bdc1fdd508
2 changed files with 21 additions and 2 deletions
|
|
@ -244,6 +244,25 @@ def _bump(cfg: config.Config, new_version: str, allow_dirty: bool = False) -> No
|
||||||
_vcs.push(new_version)
|
_vcs.push(new_version)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_diff(cfg: config.Config, new_version: str) -> None:
|
||||||
|
diff: str = rewrite.diff(new_version, cfg.file_patterns)
|
||||||
|
|
||||||
|
if sys.stdout.isatty():
|
||||||
|
for line in diff.splitlines():
|
||||||
|
if line.startswith("+++") or line.startswith("---"):
|
||||||
|
print(line)
|
||||||
|
elif line.startswith("+"):
|
||||||
|
print("\u001b[32m" + line + "\u001b[0m")
|
||||||
|
elif line.startswith("-"):
|
||||||
|
print("\u001b[31m" + line + "\u001b[0m")
|
||||||
|
elif line.startswith("@"):
|
||||||
|
print("\u001b[36m" + line + "\u001b[0m")
|
||||||
|
else:
|
||||||
|
print(line)
|
||||||
|
else:
|
||||||
|
print(diff)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("-v", "--verbose", count=True, help="Control log level. -vv for debug level.")
|
@click.option("-v", "--verbose", count=True, help="Control log level. -vv for debug level.")
|
||||||
@click.option(
|
@click.option(
|
||||||
|
|
@ -318,7 +337,7 @@ def bump(
|
||||||
|
|
||||||
if dry or verbose >= 2:
|
if dry or verbose >= 2:
|
||||||
try:
|
try:
|
||||||
print(rewrite.diff(new_version, cfg.file_patterns))
|
_print_diff(cfg, new_version)
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
log.error(str(ex))
|
log.error(str(ex))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ class VCS:
|
||||||
def status(self, required_files: typ.Set[str]) -> typ.List[str]:
|
def status(self, required_files: typ.Set[str]) -> typ.List[str]:
|
||||||
"""Get status lines."""
|
"""Get status lines."""
|
||||||
status_output = self('status')
|
status_output = self('status')
|
||||||
status_items = [line.split(" ", 1) for line in status_output.splitlines()]
|
status_items = [line.split(" ", 1) for line in status_output.splitlines()]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
filepath.strip()
|
filepath.strip()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue