more obvious handling of tag and push

This commit is contained in:
Manuel Barkhau 2018-12-22 00:37:27 +01:00
parent d46d8f075a
commit fe4b381b5b
3 changed files with 9 additions and 6 deletions

View file

@ -214,8 +214,10 @@ def _bump(cfg: config.Config, new_version: str, allow_dirty: bool = False) -> No
_vcs.commit(f"bump version to {new_version}")
if cfg.tag:
if cfg.commit and cfg.tag:
_vcs.tag(new_version)
if cfg.commit and cfg.tag and cfg.push:
_vcs.push(new_version)

View file

@ -79,8 +79,8 @@ class Config(typ.NamedTuple):
current_version: str
pep440_version : str
tag : bool
commit: bool
tag : bool
push : bool
file_patterns: PatternsByFilePath
@ -91,8 +91,8 @@ def _debug_str(cfg: Config) -> str:
f"Config Parsed: Config(",
f"current_version='{cfg.current_version}'",
f"pep440_version='{cfg.pep440_version}'",
f"tag={cfg.tag}",
f"commit={cfg.commit}",
f"tag={cfg.tag}",
f"push={cfg.push}",
"file_patterns={",
]

View file

@ -64,6 +64,9 @@ class VCS:
"""Invoke subcommand and return output."""
cmd_tmpl = self.subcommands[cmd_name]
cmd_str = cmd_tmpl.format(**kwargs)
if cmd_name in ("commit", "tag", "push_tag"):
log.info(cmd_str)
else:
log.debug(cmd_str)
output_data = sp.check_output(cmd_str.split(), env=env, stderr=sp.STDOUT)
@ -122,7 +125,6 @@ class VCS:
def add(self, path: str) -> None:
"""Add updates to be included in next commit."""
log.info(f"{self.name} add {path}")
try:
self('add_path', path=path)
except sp.CalledProcessError as ex:
@ -134,7 +136,6 @@ class VCS:
def commit(self, message: str) -> None:
"""Commit added files."""
log.info(f"{self.name} commit -m '{message}'")
message_data = message.encode("utf-8")
tmp_file = tempfile.NamedTemporaryFile("wb", delete=False)