Skip to content

Commit bc32772

Browse files
authored
Fix changelog PyPI version filtering (#48162)
* Fix changelog PyPI version filtering * update
1 parent bbfbf0c commit bc32772

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

eng/tools/azure-sdk-tools/packaging_tools/package_utils.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,17 @@ def change_log_new(package_folder: str, lastest_pypi_version: bool) -> str:
5555
def get_version_info(package_name: str, tag_is_stable: bool = False) -> Tuple[str, str]:
5656
from pypi_tools.pypi import PyPIClient
5757

58+
SDK_VERSIONS_WITH_CHANGELOG_ISSUE = {}
59+
SKIP_SDK_VERSIONS = {"azure-mgmt-datatransfer": "1.0.0b1"} # could be removed after new SDK version released
60+
5861
try:
59-
client = PyPIClient()
60-
# Ignore 0.0.0 when it appears on PyPI as a placeholder or name-reservation version.
61-
ordered_versions = [v for v in client.get_ordered_versions(package_name) if v.base_version != "0.0.0"]
62+
client = PyPIClient(force_pypi=True)
63+
# Ignore 0.0.0 placeholder releases, including prereleases like 0.0.0b1 via base_version.
64+
ordered_versions = [
65+
v
66+
for v in client.get_ordered_versions(package_name)
67+
if v.base_version != "0.0.0" and str(v) != SKIP_SDK_VERSIONS.get(package_name)
68+
]
6269
if not ordered_versions:
6370
return "", ""
6471
last_release = ordered_versions[-1]
@@ -72,10 +79,9 @@ def get_version_info(package_name: str, tag_is_stable: bool = False) -> Tuple[st
7279
# temporary logic to always get latest version from pypi for specific packages whose latest stable version
7380
# is not updated for a long time and has some issue in changelog generation.
7481
# This is a workaround before we have a better solution to determine the version for changelog generation.
75-
sdks_with_changelog_issue = {}
76-
if package_name in sdks_with_changelog_issue and (
77-
last_version == sdks_with_changelog_issue[package_name]
78-
or last_stable_version == sdks_with_changelog_issue[package_name]
82+
if package_name in SDK_VERSIONS_WITH_CHANGELOG_ISSUE and (
83+
last_version == SDK_VERSIONS_WITH_CHANGELOG_ISSUE[package_name]
84+
or last_stable_version == SDK_VERSIONS_WITH_CHANGELOG_ISSUE[package_name]
7985
):
8086
_LOGGER.info(
8187
f"Package {package_name} has changelog generation issue with version {last_version}, fallback to get latest version from pypi"

eng/tools/azure-sdk-tools/tests/test_package_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,14 @@ def test_get_version_info_does_not_filter_0_0_0_1():
107107
result = pu.get_version_info("azure-some-package", tag_is_stable=False)
108108

109109
assert result == ("0.0.0.1", "0.0.0.1")
110+
111+
112+
def test_get_version_info_skips_package_specific_version():
113+
with patch("pypi_tools.pypi.PyPIClient") as MockClient:
114+
mock_client = MagicMock()
115+
MockClient.return_value = mock_client
116+
mock_client.get_ordered_versions.return_value = [Version("0.9.0"), Version("1.0.0b1")]
117+
118+
result = pu.get_version_info("azure-mgmt-datatransfer", tag_is_stable=False)
119+
120+
assert result == ("0.9.0", "0.9.0")

0 commit comments

Comments
 (0)