mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
199 stars 36 forks source link

VCS configuration via command line parameters #168

Closed timobrembeck closed 3 years ago

timobrembeck commented 3 years ago

I really love this tool, I just miss the ability to override the vcs options in the config file via the command line.

For example, in my CI workflow I want to bump the version and only commit & tag under certain conditions. It feels kind of hacky to change the config script via sed or similar when automating these tasks.

I would like to have the possibility to pass e.g. an option --commit/--no-commit to override anything configured in bumpver.toml. If you think that's a functionality more people would benefit from, I could give it a shot and open a PR for this.

mbarkhau commented 3 years ago

That sounds like a reasonable feature request.

The main thing to watch out for is to not change existing behaviour. In other words, if you would like to add --commit/--no-commit then this is not two states but three: (True, False, None).

Just spitballing, without considering other changes required in src/bumpver/cli.py.

# src/bumpver/config.py
def init(
    project_path  : typ.Union[str, pl.Path, None] = ".",
    cfg_missing_ok: bool = False,
    commit        : Optional[bool] = None,
) -> typ.Tuple[ProjectContext, MaybeConfig]:
    ctx = init_project_ctx(project_path)
    cfg = parse(ctx, cfg_missing_ok)
    if commit is not None:
        cfg = cfg._replace(commit=commit)
    return (ctx, cfg)
mbarkhau commented 3 years ago

Published: https://pypi.org/project/bumpver/2021.1114/