str_version = version.get_str_version()
git_version = version.get_git_version()
- str_re = r'v\d\.\d\.\d(\.alpha-0)?' # v1.2.3-alpha-0
- git_re = r'v\d\.\d\.\d(\.post\d+-\w+)?' # v1.2.3.post1-abc123
+ str_re = r'v\d\.\d\.\d(([ab]|rc)\d+)?' # v1.2.3a0
+ git_re = r'v\d\.\d\.\d(\.post\d+\+\w+)?' # v1.2.3.post1+abc123
str_match = re.match(str_re, version.format_str_version(str_version))
git_match = re.match(git_re, version.format_git_version(git_version))
def format_str_version(version):
"""Format version tuple."""
- return 'v' + '.'.join(
+ return 'v' + ''.join(
[
'.'.join([str(x) for x in version[:3]]),
- '-'.join([str(x) for x in version[3:]]),
+ ''.join([str(x) for x in version[3:]]),
]
)
def format_git_version(version):
"""Returns a version based on Git tags."""
if '-' in version: # after tag
- # convert version-N-githash to version.postN-githash
- return version.replace('-', '.post', 1)
+ # convert version-N-githash to version.postN+githash
+ return version.replace('-', '.post', 1).replace('-g', '+git', 1)
else: # at tag
return version