Skip to content

Commit

Permalink
{CI} Fix script re for version extract (#7649)
Browse files Browse the repository at this point in the history
* fix script re

* set output for empty module list
  • Loading branch information
AllyW authored May 22, 2024
1 parent ed5c231 commit 0ee8208
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/ci/release_version_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def extract_module_version_update_info(mod_update_info, mod):
"""
mod_update_info["setup_updated"] = False
module_setup_update_pattern = re.compile(r"\+\+\+.*?src/%s/setup.py" % mod)
module_version_update_pattern = re.compile(r"\+.*?VERSION.*?\=.*?[\'\"]([0-9\.b]+)[\'\"]")
module_version_update_pattern = re.compile(r"\+\s?VERSION\s?\=\s?[\'\"]([0-9\.b]+)[\'\"]")
with open(diff_code_file, "r") as f:
for line in f:
if mod_update_info["setup_updated"]:
if line.find("---") != -1 or mod_update_info.get("version_diff", None):
if line.find("---") == 0 or mod_update_info.get("version_diff", None):
break
mod_version_update_match = re.findall(module_version_update_pattern, line)
if mod_version_update_match and len(mod_version_update_match) == 1:
Expand Down Expand Up @@ -93,7 +93,7 @@ def extract_module_metadata_update_info(mod_update_info, mod):
with open(diff_code_file, "r") as f:
for line in f:
if mod_update_info["meta_updated"]:
if line.find("---") != -1:
if line.find("---") == 0:
break
ispreview_add_match = re.findall(module_ispreview_add_pattern, line)
if ispreview_add_match and len(ispreview_add_match):
Expand Down Expand Up @@ -226,7 +226,7 @@ def gen_preview_comment_message(mod, mod_update_info, mod_message):
if mod_update_info.get("preview_tag", "-") == mod_update_info.get("preview_tag_diff", "-"):
return
preview_comment_message = " - "
if mod_update_info["setup_updated"]:
if mod_update_info["setup_updated"] and mod_update_info.get("version_diff", None):
block_pr = 1
preview_comment_message += ":warning: "
if mod_update_info.get("preview_tag", None) and mod_update_info.get("preview_tag_diff", None):
Expand Down Expand Up @@ -317,11 +317,13 @@ def main():
if len(changed_module_list) == 0:
comment_message.append("For more info about extension versioning, please refer to [Extension version schema](https://github.com/Azure/azure-cli/blob/release/doc/extensions/versioning_guidelines.md)")
save_comment_message(output_file, comment_message)
save_gh_output()
return
fill_module_update_info(modules_update_info)
if len(modules_update_info) == 0:
comment_message.append("For more info about extension versioning, please refer to [Extension version schema](https://github.com/Azure/azure-cli/blob/release/doc/extensions/versioning_guidelines.md)")
save_comment_message(output_file, comment_message)
save_gh_output()
return
for mod, update_info in modules_update_info.items():
gen_comment_message(mod, update_info, comment_message)
Expand Down

0 comments on commit 0ee8208

Please sign in to comment.