From fd6cda1239cbf48bf7d5fa250b8f2c99dd80738a Mon Sep 17 00:00:00 2001 From: Neves-P Date: Wed, 14 Feb 2024 16:36:09 +0100 Subject: [PATCH] Move text snippets to cfg_file --- app.cfg.example | 8 ++++++++ tasks/build.py | 32 +++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app.cfg.example b/app.cfg.example index 57d09bbb..1888e499 100644 --- a/app.cfg.example +++ b/app.cfg.example @@ -221,3 +221,11 @@ job_result_unknown_fmt =
:shrug: UNKNOWN _(click triangle for job_test_unknown_fmt =
:shrug: UNKNOWN _(click triangle for detailed information)_
  • Job test file `{filename}` does not exist in job directory, or parsing it failed.
[download_pr_comments] +git_clone_failure = Unable to clone the target repository. +git_clone_tip = _Tip: This could be a connection failure. Try again and if the issue remains check if the address is correct_. +git_checkout_failure = Unable to checkout to the correct branch. +git_checkout_tip = _Tip: Ensure that the branch name is correct and the target branch is available._ +curl_failure = Unable to download the `.diff` file. +curl_tip = _Tip: This could be a connection failure. Try again and if the issue remains check if the address is correct_ +git_apply_failure = Unable to download or merge changes between the source branch and the destination branch. +git_apply_tip = _Tip: This can usually be resolved by syncing your branch and resolving any merge conflicts._ diff --git a/tasks/build.py b/tasks/build.py index 87f0cd2d..473599b6 100644 --- a/tasks/build.py +++ b/tasks/build.py @@ -40,13 +40,22 @@ BUILD_PERMISSION = "build_permission" CFG_DIRNAME = "cfg" CONTAINER_CACHEDIR = "container_cachedir" +CURL_FAILURE = "curl_failure" +CURL_TIP = "curl_tip" CVMFS_CUSTOMIZATIONS = "cvmfs_customizations" DEFAULT_JOB_TIME_LIMIT = "24:00:00" +DOWNLOAD_PR_COMMENTS = "download_pr_comments" ERROR_CURL = "curl" ERROR_GIT_APPLY = "git apply" ERROR_GIT_CHECKOUT = "git checkout" ERROR_GIT_CLONE = "curl" GITHUB = "github" +GIT_CLONE_FAILURE = "git_clone_failure" +GIT_CLONE_TIP = "git_clone_tip" +GIT_CHECKOUT_FAILURE = "git_checkout_failure" +GIT_CHECKOUT_TIP = "git_checkout_tip" +GIT_APPLY_FAILURE = "git_apply_failure" +GIT_APPLY_TIP = "git_apply_tip" HTTPS_PROXY = "https_proxy" HTTP_PROXY = "http_proxy" INITIAL_COMMENT = "initial_comment" @@ -410,27 +419,24 @@ def comment_download_pr(base_repo_name, pr, download_pr_exit_code, download_pr_e """ if download_pr_exit_code != 0: fn = sys._getframe().f_code.co_name + + download_pr_comments_cfg = config.read_config()[DOWNLOAD_PR_COMMENTS] if error_stage == ERROR_GIT_CLONE: download_comment = (f"`{download_pr_error}`" - f"\nUnable to clone the target repository." - f"\n_Tip: This could be a connection failure." - f" Try again and if the issue remains check if the address is correct_.") + f"{download_pr_comments_cfg[GIT_CLONE_FAILURE]}" + f"{download_pr_comments_cfg[GIT_CLONE_TIP]}") elif error_stage == ERROR_GIT_CHECKOUT: download_comment = (f"`{download_pr_error}`" - f"\nUnable to checkout to the correct branch." - f"\n_Tip: Ensure that the branch name is correct and the target" - " branch is available._") + f"{download_pr_comments_cfg[GIT_CHECKOUT_FAILURE]}" + f"{download_pr_comments_cfg[GIT_CHECKOUT_TIP]}") elif error_stage == ERROR_CURL: download_comment = (f"`{download_pr_error}`" - f"\nUnable to download the .diff file." - f"\n_Tip: This could be a connection failure." - f" Try again and if the issue remains check if the address is correct_") + f"{download_pr_comments_cfg[CURL_FAILURE]}" + f"{download_pr_comments_cfg[CURL_TIP]}") elif error_stage == ERROR_GIT_APPLY: download_comment = (f"`{download_pr_error}`" - f"\nUnable to download or merge changes between the source" - f" branch and the destination branch.\n" - f"\n_Tip: This can usually be resolved by syncing your" - f" branch and resolving any merge conflicts._") + f"{download_pr_comments_cfg[GIT_APPLY_FAILURE]}" + f"{download_pr_comments_cfg[GIT_APPLY_TIP]}") download_comment = pr_comments.create_comment( repo_name=base_repo_name, pr_number=pr.number, comment=download_comment