turbaszek commented on a change in pull request #13767:
URL: https://github.com/apache/airflow/pull/13767#discussion_r567717505



##########
File path: dev/provider_packages/prepare_provider_packages.py
##########
@@ -830,87 +859,17 @@ def convert_cross_package_dependencies_to_table(
 )
 
 
-def strip_leading_zeros_in_calver(calver_version: str) -> str:
+def strip_leading_zeros(version: str) -> str:
     """
-    Strips leading zeros from calver version number.
+    Strips leading zeros from version number.
 
     This converts 1974.04.03 to 1974.4.3 as the format with leading month and 
day zeros is not accepted
     by PIP versioning.
 
-    :param calver_version: version number in calver format (potentially with 
leading 0s in date and month)
+    :param version: version number in calver format (potentially with leading 
0s in date and month)
     :return: string with leading 0s after dot replaced.
     """
-    return calver_version.replace(".0", ".")
-
-
-def get_provider_changes_prefix(backport_packages: bool) -> str:
-    """
-    Returns prefix for provider CHANGES files.
-    """
-    if backport_packages:
-        return "BACKPORT_PROVIDER_CHANGES_"
-    else:
-        return "PROVIDER_CHANGES_"
-
-
-def get_all_releases(provider_package_path: str, backport_packages: bool) -> 
List[ReleaseInfo]:
-    """
-    Returns information about past releases (retrieved from *changes_*md files 
stored in the
-    package folder.
-    :param provider_package_path: path of the package
-    :param backport_packages: whether to prepare regular (False) or backport 
(True) packages
-    :return: list of releases made so far.
-    """
-    changes_file_prefix = 
get_provider_changes_prefix(backport_packages=backport_packages)
-    past_releases: List[ReleaseInfo] = []
-    changes_file_names = listdir(provider_package_path)
-    for file_name in sorted(changes_file_names, reverse=True):
-        if file_name.startswith(changes_file_prefix) and 
file_name.endswith(".md"):
-            changes_file_path = os.path.join(provider_package_path, file_name)
-            with open(changes_file_path) as changes_file:
-                content = changes_file.read()
-            found = re.search(r'/([a-z0-9]*)\)', content, flags=re.MULTILINE)
-            if not found:
-                print("[yellow]No commit found. This seems to be first time 
you run it[/]", file=sys.stderr)
-            else:
-                last_commit_hash = found.group(1)
-                release_version = file_name[len(changes_file_prefix) :][:-3]
-                release_version_no_leading_zeros = (
-                    strip_leading_zeros_in_calver(release_version) if 
backport_packages else release_version
-                )
-                past_releases.append(
-                    ReleaseInfo(
-                        release_version=release_version,
-                        
release_version_no_leading_zeros=release_version_no_leading_zeros,
-                        last_commit_hash=last_commit_hash,
-                        content=content,
-                        file_name=file_name,
-                    )
-                )
-    return past_releases
-
-
-def get_latest_release(provider_package_path: str, backport_packages: bool) -> 
ReleaseInfo:
-    """
-    Gets information about the latest release.
-
-    :param provider_package_path: path of package
-    :param backport_packages: whether to prepare regular (False) or backport 
(True) packages
-    :return: latest release information
-    """
-    releases = get_all_releases(
-        provider_package_path=provider_package_path, 
backport_packages=backport_packages
-    )
-    if len(releases) == 0:
-        return ReleaseInfo(
-            release_version="0.0.0",
-            release_version_no_leading_zeros="0.0.0",
-            last_commit_hash="no_hash",
-            content="empty",
-            file_name="no_file",
-        )
-    else:
-        return releases[0]
+    return ".".join(str(int(i)) for i in version.split("."))

Review comment:
       Is there need to cast to `int` if we then cast to `str`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to