diff --git a/HISTORY.rst b/HISTORY.rst index e79fafb1..dbf6e70f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +0.1.77 +++++++ +* `azdev extension cal-next-version`: Fix pre_num when tagged preview version with `major`, `minor`, `patch`. + 0.1.76 ++++++ * `azdev extension cal-next-version`: Fix preview to stable version case. diff --git a/azdev/__init__.py b/azdev/__init__.py index d7d8251f..067aaaad 100644 --- a/azdev/__init__.py +++ b/azdev/__init__.py @@ -4,4 +4,4 @@ # license information. # ----------------------------------------------------------------------------- -__VERSION__ = '0.1.76' +__VERSION__ = '0.1.77' diff --git a/azdev/operations/extensions/version_upgrade.py b/azdev/operations/extensions/version_upgrade.py index 610e5fec..54f65db1 100644 --- a/azdev/operations/extensions/version_upgrade.py +++ b/azdev/operations/extensions/version_upgrade.py @@ -132,13 +132,16 @@ def update_next_version(self): self.next_version.major = self.version.major + 1 self.next_version.minor = 0 self.next_version.patch = 0 + self.next_version.pre_num = 1 elif self.next_version_segment_tag == VERSION_MINOR_TAG: self.next_version.minor = self.version.minor + 1 self.next_version.patch = 0 + self.next_version.pre_num = 1 elif self.next_version_segment_tag == VERSION_PATCH_TAG: self.next_version.patch = self.version.micro + 1 + self.next_version.pre_num = 1 elif self.next_version_segment_tag == VERSION_PRE_TAG: - self.next_version.patch = (self.version.pre and self.version.pre[1] or 0) + 1 + self.next_version.pre_num = (self.version.pre and self.version.pre[1] or 0) + 1 else: raise ValueError("Unsupported segment tag: {0}".format(self.next_version_segment_tag)) return @@ -159,6 +162,8 @@ def update_version_from_differs(self): self.next_version.major = self.version.major + 1 self.next_version.minor = 0 self.next_version.patch = 0 + if self.is_preview: + self.next_version.pre_num = 1 elif len(self.diffs) > 0: if self.is_preview: self.next_version.pre_num = self.version.pre[1] + 1 diff --git a/azdev/operations/tests/test_extension_versioning.py b/azdev/operations/tests/test_extension_versioning.py index 684f1204..bd9693e9 100644 --- a/azdev/operations/tests/test_extension_versioning.py +++ b/azdev/operations/tests/test_extension_versioning.py @@ -68,6 +68,30 @@ def test_version_upgrade_to_normal_version(self): self.assertEqual(False, version_test.get("is_stable"), "Version tag error") self.assertEqual(False, version_test.get("preview_tag", False), "Version tag error") + def test_version_upgrade_major_tagged_from_preview(self): + # preview version update pre num but user tagged major + version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), + diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_after.json"), + current_version="3.11.0b7", next_version_segment_tag="major") + self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error") + self.assertEqual(False, version_test.get("is_stable"), "Version tag error") + + def test_version_upgrade_minor_tagged_from_preview(self): + # preview version update pre num but user tagged minor + version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), + diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_after.json"), + current_version="3.11.0b7", next_version_segment_tag="minor") + self.assertEqual("3.12.0b1", version_test.get("version"), "Version cal error") + self.assertEqual(False, version_test.get("is_stable"), "Version tag error") + + def test_version_upgrade_patch_tagged_from_preview(self): + # preview version update pre num but user tagged patch + version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), + diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_after.json"), + current_version="3.11.0b7", next_version_segment_tag="patch") + self.assertEqual("3.11.1b1", version_test.get("version"), "Version cal error") + self.assertEqual(False, version_test.get("is_stable"), "Version tag error") + def test_version_upgrade_minor_tagged(self): # stable version update minor as user tagged version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), @@ -83,6 +107,22 @@ def test_version_upgrade_patch_tagged(self): current_version="3.11.0", next_version_segment_tag="patch") self.assertEqual("3.11.1", version_test.get("version"), "Version cal error") + def test_version_upgrade_pre_tagged(self): + # preview version update major but user tagged pre + version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), + diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_after.json"), + current_version="3.11.0b7", next_version_segment_tag="pre") + self.assertEqual("3.11.0b8", version_test.get("version"), "Version cal error") + self.assertEqual(False, version_test.get("is_stable"), "Version tag error") + + def test_version_upgrade_pre_untagged(self): + # preview version update major, no tag, follow no major update more than once from last stable version rule + version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_before.json"), + diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_monitor_meta_after.json"), + current_version="3.11.0b7") + self.assertEqual("4.0.0b1", version_test.get("version"), "Version cal error") + self.assertEqual(False, version_test.get("is_stable"), "Version tag error") + def test_version_upgrade_patch(self): # stable version update patch as breaking change detects empty version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons", "az_ams_meta_before.json"),