diff --git a/scripts/ci/release_version_cal.py b/scripts/ci/release_version_cal.py index fc3cc4a0f19..abb818551be 100644 --- a/scripts/ci/release_version_cal.py +++ b/scripts/ci/release_version_cal.py @@ -28,6 +28,7 @@ DEFAULT_VERSION = "0.0.0" INIT_RELEASE_VERSION = "1.0.0b1" +DEFAULT_MESSAGE = " - 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)" block_pr = 0 cli_ext_path = get_ext_repo_paths()[0] @@ -53,27 +54,30 @@ def extract_module_history_update_info(mod_update_info, mod): def extract_module_version_update_info(mod_update_info, mod): """ re pattern: - --- a/src/monitor-control-service/setup.py - +++ b/src/monitor-control-service/setup.py + --- a/src/monitor-control-service/*.py + +++ b/src/monitor-control-service/*.py -VERSION = '1.0.1' +VERSION = '1.1.1' --- a/src/monitor-control-service/HISTORY.RST """ - mod_update_info["setup_updated"] = False - module_setup_update_pattern = re.compile(r"\+\+\+.*?src/%s/setup.py" % mod) + mod_update_info["version_updated"] = False + module_py_update_pattern = re.compile(r"\+\+\+.*?src/%s/.*?\.py" % mod) module_version_update_pattern = re.compile(r"\+\s?VERSION\s?\=\s?[\'\"]([0-9\.b]+)[\'\"]") + isPyFile = False with open(diff_code_file, "r") as f: for line in f: - if mod_update_info["setup_updated"]: - if line.find("---") == 0 or mod_update_info.get("version_diff", None): - break + if isPyFile: + if line.find("---") == 0: + isPyFile = False + continue mod_version_update_match = re.findall(module_version_update_pattern, line) if mod_version_update_match and len(mod_version_update_match) == 1: mod_update_info["version_diff"] = mod_version_update_match[0] + mod_update_info["version_updated"] = True else: - mod_setup_update_match = re.findall(module_setup_update_pattern, line) - if mod_setup_update_match: - mod_update_info["setup_updated"] = True + mod_py_update_match = re.findall(module_py_update_pattern, line) + if mod_py_update_match: + isPyFile = True def extract_module_metadata_update_info(mod_update_info, mod): @@ -206,7 +210,7 @@ def gen_history_comment_message(mod, mod_update_info, mod_message): def gen_version_comment_message(mod, mod_update_info, mod_message): global block_pr - if not mod_update_info["setup_updated"]: + if not mod_update_info["version_updated"]: if mod_update_info.get("version", None): mod_message.append(" - Update `VERSION` to `{0}` in `src/{1}/setup.py`".format(mod_update_info.get("version", "-"), mod)) else: @@ -227,7 +231,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"] and mod_update_info.get("version_diff", None): + if mod_update_info["version_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): @@ -253,7 +257,7 @@ def gen_exp_comment_message(mod, mod_update_info, mod_message): if mod_update_info.get("exp_tag", "-") == mod_update_info.get("exp_tag_diff", "-"): return exp_comment_message = " - " - if mod_update_info["setup_updated"]: + if mod_update_info["version_updated"]: block_pr = 1 exp_comment_message += ":warning: " if mod_update_info.get("exp_tag", None) and mod_update_info.get("exp_tag_diff", None): @@ -292,7 +296,7 @@ def add_label_hint_message(comment_message): comment_message.append(" - Major/minor/patch/pre increment of version number is calculated by pull request " "code changes automatically. " "If needed, please add `major`/`minor`/`patch`/`pre` label to adjust it.") - 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)") + comment_message.append(DEFAULT_MESSAGE) def save_comment_message(file_name, comment_message): @@ -316,13 +320,13 @@ def main(): comment_message = [] modules_update_info = {} 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)") + comment_message.append(DEFAULT_MESSAGE) 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)") + comment_message.append(DEFAULT_MESSAGE) save_comment_message(output_file, comment_message) save_gh_output() return @@ -332,7 +336,7 @@ def main(): add_suggest_header(comment_message) add_label_hint_message(comment_message) else: - 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)") + comment_message.append(DEFAULT_MESSAGE) print("comment_message:") print(comment_message) print("block_pr:", block_pr)