Improve version updating; remove dead code (#4016)
This commit is contained in:
parent
407d5c853d
commit
7f0475fc18
@ -66,18 +66,11 @@ def is_master_branch():
|
|||||||
return tag_branch in [b"master\n"]
|
return tag_branch in [b"master\n"]
|
||||||
|
|
||||||
|
|
||||||
def git_tag_name():
|
|
||||||
cmd = "git describe --tags"
|
|
||||||
tag_branch = subprocess.check_output(cmd, shell=True)
|
|
||||||
tag_branch = tag_branch.decode().strip()
|
|
||||||
return tag_branch
|
|
||||||
|
|
||||||
|
|
||||||
def get_git_version_info():
|
def get_git_version_info():
|
||||||
cmd = "git describe --tags"
|
cmd = "git describe --tags"
|
||||||
ver_str = subprocess.check_output(cmd, shell=True)
|
ver_str = subprocess.check_output(cmd, shell=True)
|
||||||
ver, commits_since, githash = ver_str.decode().strip().split("-")
|
ver, commits_since, githash = ver_str.decode().strip().split("-")
|
||||||
return ver, commits_since, githash
|
return Version(ver), int(commits_since), githash
|
||||||
|
|
||||||
|
|
||||||
def prerelease_version():
|
def prerelease_version():
|
||||||
@ -88,16 +81,10 @@ def prerelease_version():
|
|||||||
ver, commits_since, githash = get_git_version_info()
|
ver, commits_since, githash = get_git_version_info()
|
||||||
initpy_ver = get_version()
|
initpy_ver = get_version()
|
||||||
|
|
||||||
assert len(initpy_ver.split(".")) in [
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
], "moto/__init__.py version should be like 0.0.2.dev"
|
|
||||||
assert (
|
assert (
|
||||||
initpy_ver > ver
|
initpy_ver > ver
|
||||||
), "the moto/__init__.py version should be newer than the last tagged release."
|
), "the moto/__init__.py version should be newer than the last tagged release."
|
||||||
return "{initpy_ver}{commits_since}".format(
|
return "{}.{}.{}.dev{}".format(initpy_ver.major, initpy_ver.minor, initpy_ver.micro, commits_since)
|
||||||
initpy_ver=initpy_ver, commits_since=commits_since
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def read(*parts):
|
def read(*parts):
|
||||||
@ -114,9 +101,14 @@ def get_version():
|
|||||||
version_match = re.search(
|
version_match = re.search(
|
||||||
r'^__version__ = [\'"]([^\'"]*)[\'"]', version_file, re.MULTILINE
|
r'^__version__ = [\'"]([^\'"]*)[\'"]', version_file, re.MULTILINE
|
||||||
)
|
)
|
||||||
if version_match:
|
if not version_match:
|
||||||
return version_match.group(1)
|
raise RuntimeError("Unable to find version string.")
|
||||||
raise RuntimeError("Unable to find version string.")
|
initpy_ver = version_match.group(1)
|
||||||
|
assert len(initpy_ver.split(".")) in [
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
], "moto/__init__.py version should be like 0.0.2.dev"
|
||||||
|
return Version(initpy_ver)
|
||||||
|
|
||||||
|
|
||||||
def increase_patch_version(old_version):
|
def increase_patch_version(old_version):
|
||||||
@ -124,8 +116,7 @@ def increase_patch_version(old_version):
|
|||||||
:param old_version: 2.0.1
|
:param old_version: 2.0.1
|
||||||
:return: 2.0.2.dev
|
:return: 2.0.2.dev
|
||||||
"""
|
"""
|
||||||
v = Version(old_version)
|
return "{}.{}.{}.dev".format(old_version.major, old_version.minor, old_version.micro + 1)
|
||||||
return "{}.{}.{}.dev".format(v.major, v.minor, v.micro + 1)
|
|
||||||
|
|
||||||
|
|
||||||
def release_version_correct():
|
def release_version_correct():
|
||||||
@ -149,10 +140,6 @@ def release_version_correct():
|
|||||||
migrate_version(initpy, new_version)
|
migrate_version(initpy, new_version)
|
||||||
else:
|
else:
|
||||||
assert False, "No non-master deployments yet"
|
assert False, "No non-master deployments yet"
|
||||||
# check that we are a tag with the same version as in __init__.py
|
|
||||||
assert (
|
|
||||||
get_version() == git_tag_name()
|
|
||||||
), "git tag/branch name not the same as moto/__init__.py __verion__"
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user