more vcs integration

This commit is contained in:
Manuel Barkhau 2018-11-11 15:15:14 +01:00
parent fc937ddf8d
commit 181da8c930
3 changed files with 24 additions and 9 deletions

View file

@ -240,4 +240,11 @@ def bump(
if dry or not cfg.commit: if dry or not cfg.commit:
return return
# TODO (mb 2018-09-04): add files and commit for filepath in filepaths:
_vcs.add(filepath)
_vcs.commit(f"bump version to {new_version}")
if cfg.tag:
_vcs.tag(new_version)
_vcs.push()

View file

@ -119,6 +119,11 @@ def _parse_buffer(cfg_buffer: io.StringIO, config_filename: str = "<pycalver.cfg
if file_patterns is None: if file_patterns is None:
return None return None
if tag and not commit:
log.error(f"Invalid configuration in {config_filename}")
log.error(" pycalver.commit = True required if pycalver.tag = True")
return None
cfg = Config(current_version, tag, commit, file_patterns) cfg = Config(current_version, tag, commit, file_patterns)
log.debug(cfg._debug_str()) log.debug(cfg._debug_str())

View file

@ -69,6 +69,9 @@ class VCS:
return False return False
raise raise
def fetch(self) -> None:
self('fetch')
def status(self) -> typ.List[str]: def status(self) -> typ.List[str]:
status_output = self('status') status_output = self('status')
return [ return [
@ -77,8 +80,12 @@ class VCS:
if not line.strip().startswith(b"??") if not line.strip().startswith(b"??")
] ]
def fetch(self) -> None: def ls_tags(self) -> typ.List[str]:
self('fetch') ls_tag_lines = self('ls_tags').splitlines()
log.debug(f"ls_tags output {ls_tag_lines}")
return [
line.decode("utf-8").strip() for line in ls_tag_lines if line.strip().startswith(b"v")
]
def add(self, path) -> None: def add(self, path) -> None:
log.info(f"{self.name} add {path}") log.info(f"{self.name} add {path}")
@ -104,12 +111,8 @@ class VCS:
def tag(self, name) -> None: def tag(self, name) -> None:
self('tag', name=name) self('tag', name=name)
def ls_tags(self) -> typ.List[str]: def push(self) -> None:
ls_tag_lines = self('ls_tags').splitlines() self('push')
log.debug(f"ls_tags output {ls_tag_lines}")
return [
line.decode("utf-8").strip() for line in ls_tag_lines if line.strip().startswith(b"v")
]
def __repr__(self) -> str: def __repr__(self) -> str:
return f"VCS(name='{self.name}')" return f"VCS(name='{self.name}')"