Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_config(working_path: Path) -> Config:
tbump_path = working_path / "tbump.toml"
try:
config = tbump.config.parse(tbump_path)
except IOError as io_error:
raise InvalidConfig(io_error=io_error)
except Exception as parse_error:
raise InvalidConfig(parse_error=parse_error)
return config
def version_from_git_tag(git_tag):
prefix = "v"
assert git_tag.startswith(prefix), "tag should start with %s" % prefix
tbump_cfg = tbump.config.parse(Path("tbump.toml"))
regex = tbump_cfg.version_regex
version = git_tag[len(prefix):]
match = regex.match(version)
assert match, "Could not parse %s as a valid tag" % git_tag
return version
def bump_files(new_version: str, repo_path: Path = None) -> None:
repo_path = repo_path or Path(".")
bumper = FileBumper(repo_path)
cfg = tbump.config.parse(repo_path / "tbump.toml")
bumper.set_config(cfg)
patches = bumper.get_patches(new_version=new_version)
n = len(patches)
for i, patch in enumerate(patches):
ui.info_count(i, n, patch.src)
patch.print_self()
patch.apply()