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

Plugin does not detect git tags? #185

Closed
kzych-inpost opened this issue Jun 24, 2024 · 5 comments
Closed

Plugin does not detect git tags? #185

kzych-inpost opened this issue Jun 24, 2024 · 5 comments

Comments

@kzych-inpost
Copy link

Hi,
I have my poetry (1.8.3) installed with pipx.
I installed the plugin using:

pipx inject poetry "poetry-dynamic-versioning[plugin]

and modified pyproject.toml:

[tool.poetry]
version = "0.0.0" 

...

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend" 

[tool.poetry-dynamic-versioning]

enable = true
vcs = "git"
style = "semver"

Although the plugin works, it does not detect tags, only appends the commit hash:

$ poetry version -s
0.0.0-post.63+978c2c3

$ git tag --points-at HEAD | cat
0.7.4

I would also add, that although I've installed the plugin as mentioned above, straightforward uninstalling leads to an error:

$ pipx uninject poetry "poetry-dynamic-versioning[plugin]"
poetry-dynamic-versioning[plugin] is not in the poetry venv. Skipping.

Only this works:

$ pipx uninject poetry "poetry-dynamic-versioning"
Uninjected package poetry-dynamic-versioning and its dependencies from venv poetry ✨ 🌟 ✨

Do you have any idea what is the cause of this behaviour?

@edgarrmondragon
Copy link
Contributor

edgarrmondragon commented Jun 24, 2024

You might wanna check your tag format. The default (via Dunamai) is:

(?x)                                                        (?# ignore whitespace)
    ^v((?P<epoch>\d+)!)?(?P<base>\d+(\.\d+)*)                   (?# v1.2.3 or v1!2000.1.2)
    ([-._]?((?P<stage>[a-zA-Z]+)[-._]?(?P<revision>\d+)?))?     (?# b0)
    (\+(?P<tagged_metadata>.+))?$ 

So a v prefix is expected. You can change this with the pattern setting.

@kzych-inpost
Copy link
Author

Yes, with the v prefix it works indeed!

❯ git tag "v0.7.4"
❯ poetry version -s
0.7.4

However, I have a trouble setting any other pattern (as you suggested) - I keep getting errors:

❯ poetry version -s
Version '^\d+\.\d+\.\d+$' does not conform to the Semantic Versioning style

or after disabling the style = "semver":

❯ poetry version -s
Invalid PEP 440 version: '^\d+\.\d+\.\d+$'

@mtkennerly
Copy link
Owner

Hi! Could you share your updated config with the pattern field? Since there's a built-in pattern for this, it should look like:

[tool.poetry-dynamic-versioning]
enable = true
pattern = "default-unprefixed"

I would also add, that although I've installed the plugin as mentioned above, straightforward uninstalling leads to an error

The [plugin] optional feature is only used when installing - it's not part of the package name itself. When uninstalling, you just specify the base package name without any optional features.

@kzych-inpost
Copy link
Author

Thank you @mtkennerly, after your remark I changed pyproject.toml:

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"
pattern = "default-unprefixed"

and it works like I intended to :)

❯ git tag --points-at HEAD | cat
1.2.3
❯ poetry version -s
1.2.3

I would only suggest to update README.md to make it more obvious for other users?

@mtkennerly
Copy link
Owner

Added an example :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants