mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +01:00
better error reporting
This commit is contained in:
parent
e85485e084
commit
863bc956c7
4 changed files with 25 additions and 7 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
# Changelog for https://gitlab.com/mbarkhau/pycalver
|
# Changelog for https://gitlab.com/mbarkhau/pycalver
|
||||||
|
|
||||||
|
|
||||||
## v201902.0023
|
## v201902.0024
|
||||||
|
|
||||||
- Added: Support for globs in file patterns
|
- Added: Support for globs in file patterns.
|
||||||
|
- Fixed: Better error reporting for invalid config.
|
||||||
|
|
||||||
|
|
||||||
## v201902.0020
|
## v201902.0020
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -44,7 +44,7 @@ setuptools.setup(
|
||||||
author="Manuel Barkhau",
|
author="Manuel Barkhau",
|
||||||
author_email="mbarkhau@gmail.com",
|
author_email="mbarkhau@gmail.com",
|
||||||
url="https://gitlab.com/mbarkhau/pycalver",
|
url="https://gitlab.com/mbarkhau/pycalver",
|
||||||
version="201902.20.post1",
|
version="201902.20post1",
|
||||||
keywords="version versioning bumpversion calver",
|
keywords="version versioning bumpversion calver",
|
||||||
description="CalVer for python libraries.",
|
description="CalVer for python libraries.",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,11 @@ def _bump(cfg: config.Config, new_version: str, allow_dirty: bool = False) -> No
|
||||||
if _vcs:
|
if _vcs:
|
||||||
_assert_not_dirty(_vcs, filepaths, allow_dirty)
|
_assert_not_dirty(_vcs, filepaths, allow_dirty)
|
||||||
|
|
||||||
rewrite.rewrite(new_version, cfg.file_patterns)
|
try:
|
||||||
|
rewrite.rewrite(new_version, cfg.file_patterns)
|
||||||
|
except ValueError as ex:
|
||||||
|
log.error(str(ex))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if _vcs is None or not cfg.commit:
|
if _vcs is None or not cfg.commit:
|
||||||
return
|
return
|
||||||
|
|
@ -314,7 +318,11 @@ def bump(
|
||||||
log.info(f"New Version: {new_version}")
|
log.info(f"New Version: {new_version}")
|
||||||
|
|
||||||
if dry or verbose >= 2:
|
if dry or verbose >= 2:
|
||||||
print(rewrite.diff(new_version, cfg.file_patterns))
|
try:
|
||||||
|
print(rewrite.diff(new_version, cfg.file_patterns))
|
||||||
|
except ValueError as ex:
|
||||||
|
log.error(str(ex))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if dry:
|
if dry:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,11 @@ def _iter_file_paths(
|
||||||
file_patterns: config.PatternsByGlob
|
file_patterns: config.PatternsByGlob
|
||||||
) -> typ.Iterable[typ.Tuple[pl.Path, config.Patterns]]:
|
) -> typ.Iterable[typ.Tuple[pl.Path, config.Patterns]]:
|
||||||
for globstr, patterns in file_patterns.items():
|
for globstr, patterns in file_patterns.items():
|
||||||
for file_path_str in glob.glob(globstr):
|
file_paths = glob.glob(globstr)
|
||||||
|
if not any(file_paths):
|
||||||
|
errmsg = f"No files found for path/glob '{globstr}'"
|
||||||
|
raise ValueError(errmsg)
|
||||||
|
for file_path_str in file_paths:
|
||||||
file_path = pl.Path(file_path_str)
|
file_path = pl.Path(file_path_str)
|
||||||
yield (file_path, patterns)
|
yield (file_path, patterns)
|
||||||
|
|
||||||
|
|
@ -171,7 +175,12 @@ def diff(new_version: str, file_patterns: config.PatternsByGlob) -> str:
|
||||||
|
|
||||||
rfd = rfd_from_content(patterns, new_version, content)
|
rfd = rfd_from_content(patterns, new_version, content)
|
||||||
rfd = rfd._replace(path=str(file_path))
|
rfd = rfd._replace(path=str(file_path))
|
||||||
full_diff += "\n".join(diff_lines(rfd)) + "\n"
|
lines = diff_lines(rfd)
|
||||||
|
if len(lines) == 0:
|
||||||
|
errmsg = f"No patterns matched for '{file_path}'"
|
||||||
|
raise ValueError(errmsg)
|
||||||
|
|
||||||
|
full_diff += "\n".join(lines) + "\n"
|
||||||
|
|
||||||
full_diff = full_diff.rstrip("\n")
|
full_diff = full_diff.rstrip("\n")
|
||||||
return full_diff
|
return full_diff
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue