add exp/preview tag operation based on last and next version's tag (#445)
This commit is contained in:
Родитель
9767acba8c
Коммит
f95014f74e
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
Release History
|
Release History
|
||||||
===============
|
===============
|
||||||
|
0.1.67
|
||||||
|
++++++
|
||||||
|
* `azdev extension cal-next-version`: Justify preview/exp tag operation based on last version's tag and next version's stable/preview tag.
|
||||||
|
|
||||||
0.1.66
|
0.1.66
|
||||||
++++++
|
++++++
|
||||||
* `azdev style`: Use azdev config files when .flake8 and pylintrc are not found in azure cli/ext repo.
|
* `azdev style`: Use azdev config files when .flake8 and pylintrc are not found in azure cli/ext repo.
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
# license information.
|
# license information.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
__VERSION__ = '0.1.66'
|
__VERSION__ = '0.1.67'
|
||||||
|
|
|
@ -195,12 +195,30 @@ class VersionUpgradeMod:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(str(e))
|
raise ValueError(str(e))
|
||||||
|
|
||||||
|
def gen_preview_exp_tags(self, res_dict):
|
||||||
|
"""
|
||||||
|
if next_version is preview: due to doc generation requirement, preview tag is needed
|
||||||
|
1. preview tag need to be reserved which had previous preview tag, nothing to do
|
||||||
|
2. preview tag need to be added if previous version does not have preview tag
|
||||||
|
|
||||||
|
if next_version is stable:
|
||||||
|
remove previous existed preview tag
|
||||||
|
|
||||||
|
exp tag should be removed for stable/preview
|
||||||
|
"""
|
||||||
|
if self.has_exp_tag:
|
||||||
|
res_dict["exp_tag"] = "remove"
|
||||||
|
if self.next_version.pre:
|
||||||
|
if not self.has_preview_tag:
|
||||||
|
res_dict["preview_tag"] = "add"
|
||||||
|
else:
|
||||||
|
if self.has_preview_tag:
|
||||||
|
res_dict["preview_tag"] = "remove"
|
||||||
|
|
||||||
def format_outputs(self):
|
def format_outputs(self):
|
||||||
has_preview_tag = bool(self.next_version.pre and (self.has_preview_tag or self.has_exp_tag))
|
|
||||||
result = {
|
result = {
|
||||||
"version": str(self.next_version),
|
"version": str(self.next_version),
|
||||||
"is_stable": self.next_version.pre is None,
|
"is_stable": self.next_version.pre is None
|
||||||
"has_preview_tag": has_preview_tag,
|
|
||||||
"has_exp_tag": False
|
|
||||||
}
|
}
|
||||||
|
self.gen_preview_exp_tags(result)
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="3.11.0")
|
current_version="3.11.0")
|
||||||
self.assertEqual("4.0.0", version_test.get("version"), "Version cal error")
|
self.assertEqual("4.0.0", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(True, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(True, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(False, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual(False, version_test.get("preview_tag", False), "Version tag error")
|
||||||
|
|
||||||
def test_version_upgrade_major_was_preview(self):
|
def test_version_upgrade_major_was_preview(self):
|
||||||
# preview version update major and add preview suffix
|
# preview version update major and add preview suffix
|
||||||
|
@ -29,7 +29,7 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="3.11.0", is_preview=True)
|
current_version="3.11.0", is_preview=True)
|
||||||
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(True, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual(False, version_test.get("preview_tag", False), "Version tag error")
|
||||||
|
|
||||||
def test_version_upgrade_major_was_exp(self):
|
def test_version_upgrade_major_was_exp(self):
|
||||||
# preview version update major and add preview suffix
|
# preview version update major and add preview suffix
|
||||||
|
@ -38,7 +38,8 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="3.11.0", is_experimental=True)
|
current_version="3.11.0", is_experimental=True)
|
||||||
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(True, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual("add", version_test.get("preview_tag", False), "Version preview tag error")
|
||||||
|
self.assertEqual("remove", version_test.get("exp_tag", False), "Version exp tag error")
|
||||||
|
|
||||||
def test_version_upgrade_major_to_preview(self):
|
def test_version_upgrade_major_to_preview(self):
|
||||||
# preview version update major and add preview suffix
|
# preview version update major and add preview suffix
|
||||||
|
@ -47,7 +48,7 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="3.11.0", next_version_pre_tag="preview")
|
current_version="3.11.0", next_version_pre_tag="preview")
|
||||||
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(False, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual("add", version_test.get("preview_tag", False), "Version tag error")
|
||||||
|
|
||||||
def test_version_upgrade_to_normal_version(self):
|
def test_version_upgrade_to_normal_version(self):
|
||||||
# preview version update major and add preview suffix
|
# preview version update major and add preview suffix
|
||||||
|
@ -56,7 +57,7 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="0.11.0", is_preview=True)
|
current_version="0.11.0", is_preview=True)
|
||||||
self.assertEqual("1.0.0b1", version_test.get("version"), "Version cal error")
|
self.assertEqual("1.0.0b1", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(True, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual(False, version_test.get("preview_tag", False), "Version tag error")
|
||||||
|
|
||||||
def test_version_upgrade_minor_tagged(self):
|
def test_version_upgrade_minor_tagged(self):
|
||||||
# stable version update minor as user tagged
|
# stable version update minor as user tagged
|
||||||
|
@ -89,4 +90,4 @@ class MyTestCase(unittest.TestCase):
|
||||||
current_version="1.0.0b3")
|
current_version="1.0.0b3")
|
||||||
self.assertEqual("1.0.0b4", version_test.get("version"), "Version cal error")
|
self.assertEqual("1.0.0b4", version_test.get("version"), "Version cal error")
|
||||||
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
|
||||||
self.assertEqual(False, version_test.get("has_preview_tag"), "Version tag error")
|
self.assertEqual("add", version_test.get("preview_tag", False), "Version tag error")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче