Welcome to jaraco.versioning documentation!¶
- class jaraco.versioning.SummableVersion(version: str)¶
Bases:
VersionA special version that can be added to another Version.
>>> SummableVersion('1.1') + packaging.version.Version('2.3') <Version('3.4')>
- as_number()¶
>>> round(SummableVersion('1.9.3').as_number(), 12) 1.93
- reset_less_significant(significant_version)¶
Reset to zero all version info less significant than the indicated version.
>>> ver = SummableVersion('3.1.2') >>> ver.reset_less_significant(SummableVersion('0.1')) >>> str(ver) '3.1'
- class jaraco.versioning.Versioned¶
Bases:
objectVersion functionality mix-ins for jaraco.vcs.Repo classes.
- get_current_version(increment=None)¶
Return as a string the version of the current state of the repository – a tagged version, if present, or the next version based on prior tagged releases.
- get_latest_version()¶
Determine the latest version ever released of the project in the repo (based on tags).
- get_next_version(increment=None)¶
Return the next version based on prior tagged releases.
- get_tagged_version()¶
Get the version of the local working set as a Version or None if no viable tag exists. If the local working set is itself the tagged commit and the tip and there are no local modifications, use the tag on the parent changeset.
- get_valid_versions()¶
Return all version tags that can be represented by a Version.
- increment = 'patch'¶
- static infer_next_version(last_version, increment)¶
Given a simple application version (as a Version), and an increment (1.0, 0.1, or 0.0.1), guess the next version.
Set up a shorthand for examples.
>>> def VM_infer(*params): ... return str(VersionManagement.infer_next_version(*params))
>>> VM_infer('3.2', '0.0.1') '3.2.1' >>> VM_infer(packaging.version.Version('3.2'), '0.0.1') '3.2.1' >>> VM_infer('3.2.3', '0.1') '3.3' >>> VM_infer('3.1.2', '1.0') '4.0'
A semantic identifier (major, minor, patch) may be used.
>>> VM_infer('3.1.2', 'major') '4' >>> VM_infer('3.1.2', 'minor') '3.2' >>> VM_infer('3.1.2', 'patch') '3.1.3'
Subversions never increment parent versions.
>>> VM_infer('3.0.9', '0.0.1') '3.0.10'
If it’s a prerelease version, just remove the prerelease.
>>> VM_infer('3.1a1', '0.0.1') '3.1'
If there is no last version, use the increment itself
>>> VM_infer(None, '0.1') '0.1'
- semantic_increment = {'major': '1', 'minor': '0.1', 'patch': '0.0.1'}¶
- jaraco.versioning.find(pred, items)¶
Find the index of the first element in items for which pred returns True
>>> find(lambda x: x > 3, range(100)) 4 >>> find(lambda x: x < -3, range(100)) is None True
- jaraco.versioning.rfind(pred, items)¶
Find the index of the last element in items for which pred returns True. Returns a negative number useful for indexing from the end of a list or tuple.
>>> rfind(lambda x: x > 3, [5,4,3,2,1]) -4
- jaraco.versioning.semver(orig)¶
>>> semver('1') 'v1.0.0' >>> semver('1.2') 'v1.2.0' >>> semver('10.11.12') 'v10.11.12' >>> semver('v1.0') 'v1.0.0'