Skip to content

Commit 96acdc8

Browse files
Merge pull request #111 from baloise/fix/preview-only-one-commit
fix(create-preview,create-pr-preview): Create only one commit when creating a new preview folder
2 parents 24eb4aa + bf73bd5 commit 96acdc8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

gitopscli/commands/create_preview.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,9 @@ def create_preview_command(
8080
logging.info("Is preview env already existing? %s", preview_env_already_exist)
8181
if not preview_env_already_exist:
8282
__create_new_preview_env(
83-
git_hash,
84-
new_preview_folder_name,
85-
preview_template_folder_name,
86-
root_git,
87-
gitops_config.application_name,
83+
new_preview_folder_name, preview_template_folder_name, root_git,
8884
)
85+
8986
logging.info("Using image tag from git hash: %s", git_hash)
9087
route_host = None
9188
value_replaced = False
@@ -106,7 +103,10 @@ def create_preview_command(
106103
deployment_already_up_to_date_callback(apps_git, git_hash)
107104
return
108105

109-
root_git.commit(f"Update preview environment for '{gitops_config.application_name}' and git hash '{git_hash}'.")
106+
commit_msg_verb = "Update" if preview_env_already_exist else "Create new"
107+
root_git.commit(
108+
f"{commit_msg_verb} preview environment for '{gitops_config.application_name}' and git hash '{git_hash}'."
109+
)
110110
root_git.push("master")
111111
logging.info("Pushed branch master")
112112

@@ -154,7 +154,7 @@ def __replace_value(
154154

155155

156156
def __create_new_preview_env(
157-
git_hash, new_preview_folder_name, preview_template_folder_name, root_git, app_name,
157+
new_preview_folder_name, preview_template_folder_name, root_git,
158158
):
159159
shutil.copytree(
160160
root_git.get_full_file_path(preview_template_folder_name), root_git.get_full_file_path(new_preview_folder_name),
@@ -166,4 +166,3 @@ def __create_new_preview_env(
166166
update_yaml_file(root_git.get_full_file_path(chart_file_path), "name", new_preview_folder_name)
167167
except KeyError as ex:
168168
raise GitOpsException(f"Key 'name' not found in '{chart_file_path}'") from ex
169-
root_git.commit(f"Create new preview environment for '{app_name}' and git hash '{git_hash}'.")

0 commit comments

Comments
 (0)