Skip to content

Commit

Permalink
fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaofeiCao committed Nov 5, 2024
1 parent cc459ee commit c1d2bbb
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions eng/automation/generate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,40 +190,43 @@ def update_changelog(changelog_file, changelog):
def compare_with_maven_package(
sdk_root: str, group_id: str, service: str, previous_version: str, current_version: str, module: str
):
breaking = False
changelog = ""
breaking_changes = []

if previous_version == current_version or previous_version is None:
logging.info("[Changelog][Skip] no previous version")
return False, ""

logging.info(
"[Changelog] Compare stable version {0} with current version {1}".format(previous_version, current_version)
)

r = requests.get(
MAVEN_URL.format(
group_id=group_id.replace(".", "/"),
artifact_id=module,
version=previous_version,
else:
logging.info(
"[Changelog] Compare stable version {0} with current version {1}".format(previous_version, current_version)
)
)
r.raise_for_status()
old_jar_fd, old_jar = tempfile.mkstemp(".jar")
try:
with os.fdopen(old_jar_fd, "wb") as tmp:
tmp.write(r.content)
new_jar = os.path.join(
sdk_root,
JAR_FORMAT.format(service=service, artifact_id=module, version=current_version),

r = requests.get(
MAVEN_URL.format(
group_id=group_id.replace(".", "/"),
artifact_id=module,
version=previous_version,
)
)
if not os.path.exists(new_jar):
raise Exception("Cannot found built jar in {0}".format(new_jar))
breaking, changelog, breaking_changes = generate_changelog_and_breaking_change(sdk_root, old_jar, new_jar)
if changelog is not None:
changelog_file = os.path.join(sdk_root, CHANGELOG_FORMAT.format(service=service, artifact_id=module))
update_changelog(changelog_file, changelog)
else:
logging.error("[Changelog][Skip] Cannot get changelog")
finally:
os.remove(old_jar)
r.raise_for_status()
old_jar_fd, old_jar = tempfile.mkstemp(".jar")
try:
with os.fdopen(old_jar_fd, "wb") as tmp:
tmp.write(r.content)
new_jar = os.path.join(
sdk_root,
JAR_FORMAT.format(service=service, artifact_id=module, version=current_version),
)
if not os.path.exists(new_jar):
raise Exception("Cannot found built jar in {0}".format(new_jar))
breaking, changelog, breaking_changes = generate_changelog_and_breaking_change(sdk_root, old_jar, new_jar)
if changelog is not None:
changelog_file = os.path.join(sdk_root, CHANGELOG_FORMAT.format(service=service, artifact_id=module))
update_changelog(changelog_file, changelog)
else:
logging.error("[Changelog][Skip] Cannot get changelog")
finally:
os.remove(old_jar)
return breaking, changelog, breaking_changes


Expand Down

0 comments on commit c1d2bbb

Please sign in to comment.