Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for version number to be set #69

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions poetry_dynamic_versioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,13 @@ def _get_version(config: Mapping) -> Tuple[_DUNAMAI_VERSION_ANY, str]:
if style is not None:
style = Style(style)

version = Version.from_vcs(
vcs, config["pattern"], config["latest-tag"], config["subversion"]["tag-dir"]
)
# allow for version to be overwritten, or fetch from vcs
if "POETRY_DYNAMIC_VERSIONING_PRETEND_VERSION" in os.environ.keys:
version = Version(os.environ.get("POETRY_DYNAMIC_VERSIONING_PRETEND_VERSION"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this work, we should do a little bit of refactoring:

_get_version() currently returns both a Dunamai Version and an opaque string, but the Version isn't really needed (it's stored, but not being used currently) and is causing a complication for this new option. I think _get_version() should just immediately return the opaque string from the environment variable if it's set and ditch the Version from the return.

Since the environment variable is a backdoor, we should make sure we skip the formatting/bumping logic and use it as-is. In other words, rather than setting 1.2.3 in the env var and letting the plugin bump it to 1.2.4, I would expect to set the env var to 1.2.4 directly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to call the variable POETRY_DYNAMIC_VERSIONING_BYPASS to convey that it's bypassing the regular function of the plugin.

else:
version = Version.from_vcs(
vcs, config["pattern"], config["latest-tag"], config["subversion"]["tag-dir"]
)

if config["format-jinja"]:
version = _bump_version_per_config(version, config["bump"])
Expand Down