mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
Merge pull request #745 from codingCoffee/releasefix
fix: proper semantic version bumping
This commit is contained in:
commit
50f97e28d0
@ -154,34 +154,43 @@ def get_current_version(repo_path, to_branch):
|
||||
|
||||
def get_bumped_version(version, bump_type):
|
||||
v = semantic_version.Version(version)
|
||||
if bump_type == 'minor':
|
||||
v.minor += 1
|
||||
v.patch = 0
|
||||
v.prerelease = None
|
||||
|
||||
elif bump_type == 'major':
|
||||
if bump_type == 'major':
|
||||
v.major += 1
|
||||
v.minor = 0
|
||||
v.patch = 0
|
||||
v.prerelease = None
|
||||
|
||||
elif bump_type == 'minor':
|
||||
v.minor += 1
|
||||
v.patch = 0
|
||||
v.prerelease = None
|
||||
|
||||
elif bump_type == 'patch':
|
||||
if v.prerelease == ():
|
||||
v.patch += 1
|
||||
v.prerelease = None
|
||||
|
||||
elif len(v.prerelease) == 2:
|
||||
v.prerelease = ()
|
||||
|
||||
elif bump_type == 'stable':
|
||||
# remove pre-release tag
|
||||
v.prerelease = None
|
||||
|
||||
elif bump_type == 'prerelease':
|
||||
if v.prerelease == ():
|
||||
v.prerelease = ('beta',)
|
||||
|
||||
if len(v.prerelease)==1:
|
||||
v.patch += 1
|
||||
v.prerelease = ('beta', '1')
|
||||
else:
|
||||
|
||||
elif len(v.prerelease) == 2:
|
||||
v.prerelease = ('beta', str(int(v.prerelease[1]) + 1))
|
||||
|
||||
else:
|
||||
raise ("Something wen't wrong while doing a prerelease")
|
||||
|
||||
else:
|
||||
raise ("bump_type not amongst [major, minor, patch, prerelease]")
|
||||
|
||||
return str(v)
|
||||
|
||||
def set_version(repo_path, version, to_branch):
|
||||
|
@ -6,6 +6,7 @@ import bench.utils
|
||||
import bench.app
|
||||
import bench.config.common_site_config
|
||||
import bench.cli
|
||||
from bench.release import get_bumped_version
|
||||
|
||||
bench.cli.from_command_line = True
|
||||
|
||||
@ -20,6 +21,18 @@ class TestBenchInit(unittest.TestCase):
|
||||
if os.path.exists(bench_path):
|
||||
shutil.rmtree(bench_path, ignore_errors=True)
|
||||
|
||||
def test_semantic_version(self):
|
||||
self.assertEqual( get_bumped_version('11.0.4', 'major'), '12.0.0' )
|
||||
self.assertEqual( get_bumped_version('11.0.4', 'minor'), '11.1.0' )
|
||||
self.assertEqual( get_bumped_version('11.0.4', 'patch'), '11.0.5' )
|
||||
self.assertEqual( get_bumped_version('11.0.4', 'prerelease'), '11.0.5-beta.1' )
|
||||
|
||||
self.assertEqual( get_bumped_version('11.0.5-beta.22', 'major'), '12.0.0' )
|
||||
self.assertEqual( get_bumped_version('11.0.5-beta.22', 'minor'), '11.1.0' )
|
||||
self.assertEqual( get_bumped_version('11.0.5-beta.22', 'patch'), '11.0.5' )
|
||||
self.assertEqual( get_bumped_version('11.0.5-beta.22', 'prerelease'), '11.0.5-beta.23' )
|
||||
|
||||
|
||||
def test_init(self, bench_name="test-bench", **kwargs):
|
||||
self.init_bench(bench_name, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user