From 667c6a41f9275847b694e4df7a12a883ac062619 Mon Sep 17 00:00:00 2001 From: Christian Siegel Date: Tue, 21 Apr 2020 22:07:00 +0200 Subject: [PATCH 1/3] fix(create-preview): mention PR branch instead of config branch in commit message Now: ``` Create new preview env for application: my-app and branch: gitopscli-create-preview-f5a42195 ``` After: ``` Create new preview env for application: my-app and branch: my-feature-branch ``` --- gitopscli/commands/create_preview.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index 57609c41..7f998074 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -88,7 +88,7 @@ def create_preview_command( logging.info("Is preview env already existing for branch? %s", branch_preview_env_already_exist) if not branch_preview_env_already_exist: __create_new_preview_env( - config_branch, + pr_branch, new_preview_folder_name, preview_template_folder_name, root_git, @@ -177,7 +177,7 @@ def __no_deployment_needed(apps_git, new_image_tag, parent_id, pr_id): def __create_new_preview_env( - branch, new_preview_folder_name, preview_template_folder_name, root_git, app_name, + pr_branch, new_preview_folder_name, preview_template_folder_name, root_git, app_name, ): shutil.copytree( root_git.get_full_file_path(preview_template_folder_name), root_git.get_full_file_path(new_preview_folder_name), @@ -189,7 +189,7 @@ def __create_new_preview_env( update_yaml_file(root_git.get_full_file_path(chart_file_path), "name", new_preview_folder_name) except KeyError as ex: raise GitOpsException(f"Key 'name' not found in '{chart_file_path}'") from ex - root_git.commit(f"Create new preview env for application: {app_name} and branch: {branch}") + root_git.commit(f"Create new preview env for application: {app_name} and branch: {pr_branch}") def __create_pullrequest(branch, gitops_config, root_git): From 62e81cfb287a52d35804135d465913e81393fd6f Mon Sep 17 00:00:00 2001 From: Christian Siegel Date: Tue, 21 Apr 2020 22:22:33 +0200 Subject: [PATCH 2/3] fix(create-preview): improve commit messages and PR comments --- gitopscli/commands/create_preview.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gitopscli/commands/create_preview.py b/gitopscli/commands/create_preview.py index 7f998074..a51bbd4e 100644 --- a/gitopscli/commands/create_preview.py +++ b/gitopscli/commands/create_preview.py @@ -112,16 +112,16 @@ def create_preview_command( if not value_replaced: __no_deployment_needed(apps_git, new_image_tag, parent_id, pr_id) return - root_git.commit(f"Upated preview environment for {gitops_config.application_name} and branch {pr_branch}.") + root_git.commit(f"Update preview environment for '{gitops_config.application_name}' and branch '{pr_branch}'.") root_git.push(config_branch) logging.info("Pushed branch %s", config_branch) pr_comment_text = f""" -New Preview Environment for {gitops_config.application_name} and branch {pr_branch} created successfully. Access it here: +New preview environment for `{gitops_config.application_name}` and branch `{pr_branch}` created successfully. Access it here: https://{route_host} """ if branch_preview_env_already_exist: pr_comment_text = f""" -Preview Environment for {gitops_config.application_name} and branch {pr_branch} updated successfully. Access it here: +Preview environment for `{gitops_config.application_name}` and branch `{pr_branch}` updated successfully. Access it here: https://{route_host} """ logging.info("Creating PullRequest comment for pr with id %s and content: %s", pr_id, pr_comment_text) @@ -170,7 +170,7 @@ def __replace_value( def __no_deployment_needed(apps_git, new_image_tag, parent_id, pr_id): logging.info("The image tag %s has already been deployed. Doing nothing.", new_image_tag) pr_comment_text = f""" -The version {new_image_tag} has already been deployed. Nothing to do here. +The version `{new_image_tag}` has already been deployed. Nothing to do here. """ logging.info("Creating PullRequest comment for pr with id %s and content: %s", pr_id, pr_comment_text) apps_git.add_pull_request_comment(pr_id, pr_comment_text, parent_id) @@ -189,7 +189,7 @@ def __create_new_preview_env( update_yaml_file(root_git.get_full_file_path(chart_file_path), "name", new_preview_folder_name) except KeyError as ex: raise GitOpsException(f"Key 'name' not found in '{chart_file_path}'") from ex - root_git.commit(f"Create new preview env for application: {app_name} and branch: {pr_branch}") + root_git.commit(f"Create new preview environment for '{app_name}' and branch '{pr_branch}'.") def __create_pullrequest(branch, gitops_config, root_git): From 32274fee1cb0cfdb11e9f69fc9d0b8a9bff62879 Mon Sep 17 00:00:00 2001 From: Christian Siegel Date: Tue, 21 Apr 2020 22:23:44 +0200 Subject: [PATCH 3/3] fix(delete-preview): improve commit messages and PR comments --- gitopscli/commands/delete_preview.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gitopscli/commands/delete_preview.py b/gitopscli/commands/delete_preview.py index b7b94b8c..333212d8 100644 --- a/gitopscli/commands/delete_preview.py +++ b/gitopscli/commands/delete_preview.py @@ -74,9 +74,7 @@ def delete_preview_command( shutil.rmtree(root_git.get_full_file_path(preview_folder_name), ignore_errors=True) else: raise GitOpsException(f"There was no preview with name: {preview_folder_name}") - root_git.commit( - f"Deleted preview environment for application: {gitops_config.application_name} and branch: {branch}." - ) + root_git.commit(f"Delete preview environment for '{gitops_config.application_name}' and branch '{branch}'.") root_git.push(config_branch) logging.info("Pushed branch %s", config_branch)