Skip to content

Commit

Permalink
Merge pull request #111 from baloise/fix/preview-only-one-commit
Browse files Browse the repository at this point in the history
fix(create-preview,create-pr-preview): Create only one commit when creating a new preview folder
  • Loading branch information
christiansiegel committed Oct 7, 2020
2 parents 24eb4aa + bf73bd5 commit 96acdc8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions gitopscli/commands/create_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ def create_preview_command(
logging.info("Is preview env already existing? %s", preview_env_already_exist)
if not preview_env_already_exist:
__create_new_preview_env(
git_hash,
new_preview_folder_name,
preview_template_folder_name,
root_git,
gitops_config.application_name,
new_preview_folder_name, preview_template_folder_name, root_git,
)

logging.info("Using image tag from git hash: %s", git_hash)
route_host = None
value_replaced = False
Expand All @@ -106,7 +103,10 @@ def create_preview_command(
deployment_already_up_to_date_callback(apps_git, git_hash)
return

root_git.commit(f"Update preview environment for '{gitops_config.application_name}' and git hash '{git_hash}'.")
commit_msg_verb = "Update" if preview_env_already_exist else "Create new"
root_git.commit(
f"{commit_msg_verb} preview environment for '{gitops_config.application_name}' and git hash '{git_hash}'."
)
root_git.push("master")
logging.info("Pushed branch master")

Expand Down Expand Up @@ -154,7 +154,7 @@ def __replace_value(


def __create_new_preview_env(
git_hash, new_preview_folder_name, preview_template_folder_name, root_git, app_name,
new_preview_folder_name, preview_template_folder_name, root_git,
):
shutil.copytree(
root_git.get_full_file_path(preview_template_folder_name), root_git.get_full_file_path(new_preview_folder_name),
Expand All @@ -166,4 +166,3 @@ 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 environment for '{app_name}' and git hash '{git_hash}'.")

0 comments on commit 96acdc8

Please sign in to comment.