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

Add a "only-version" version scheme #1005

Merged
merged 10 commits into from
Jan 19, 2024
2 changes: 2 additions & 0 deletions docs/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ representing the version.
`no-guess-dev`
: Does no next version guessing, just adds `.post1.devN`

`just-version`
: Just use the version from the tag, as given.

### `setuptools_scm.local_scheme`
Configures how the local part of a version is rendered given a
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ PKG-INFO = "setuptools_scm.fallbacks:parse_pkginfo"
"post-release" = "setuptools_scm.version:postrelease_version"
"python-simplified-semver" = "setuptools_scm.version:simplified_semver_version"
"release-branch-semver" = "setuptools_scm.version:release_branch_semver_version"
"just-version" = "setuptools_scm.version:just_version"

[tool.setuptools.packages.find]
where = ["src"]
Expand Down
4 changes: 4 additions & 0 deletions src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ def release_branch_semver(version: ScmVersion) -> str:
return release_branch_semver_version(version)


def just_version(version: ScmVersion) -> str:
return version.format_with("{tag}")


def no_guess_dev_version(version: ScmVersion) -> str:
if version.exact:
return version.format_with("{tag}")
Expand Down
27 changes: 27 additions & 0 deletions testing/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from setuptools_scm.version import release_branch_semver_version
from setuptools_scm.version import ScmVersion
from setuptools_scm.version import simplified_semver_version
from setuptools_scm.version import just_version


c = Configuration()
Expand Down Expand Up @@ -169,6 +170,32 @@ def test_bump_dev_version_nonzero_raises() -> None:
with pytest.raises(ValueError, match=match):
guess_next_version(m("1.0.dev1"))

@pytest.mark.parametrize(
"version",
[
"1.dev0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"1.0.dev456",
"1.0a1",
"1.0a2.dev456",
"1.0a12.dev456",
"1.0a12",
"1.0b1.dev456",
"1.0b2",
"1.0b2.post345.dev456",
"1.0b2.post345",
"1.0rc1.dev456",
"1.0rc1",
"1.0",
"1.0.post456.dev34",
"1.0.post456",
"1.0.15",
"1.1.dev1",
],
)
def test_just_version(version: str) -> None:
assert version == just_version(meta(version, config=c))
assert version == just_version(meta(version, distance=2, config=c))


@pytest.mark.parametrize(
("tag", "expected"),
Expand Down
Loading