Skip to content

Commit e33c023

Browse files
committed
Small fixes
1 parent 43d5f3b commit e33c023

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/hermes/commands/init/base.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import os
88
import re
9+
import shutil
910
import sys
1011
import traceback
1112
import requests
@@ -270,6 +271,7 @@ def __call__(self, args: argparse.Namespace) -> None:
270271

271272
# Nice message on Ctrl+C
272273
except KeyboardInterrupt:
274+
sc.echo("")
273275
sc.echo("HERMES init was aborted.", sc.Formats.WARNING)
274276
self.clean_up_files(True)
275277
sys.exit()
@@ -416,10 +418,13 @@ def create_ci_template(self) -> None:
416418
template_url = self.get_template_url("TEMPLATE_hermes_github_to_zenodo.yml")
417419
ci_file_folder = Path(".github/workflows")
418420
ci_file_name = "hermes_github.yml"
421+
ci_file_path = ci_file_folder / ci_file_name
422+
# Adding paths to our list
423+
self.mark_as_new_path(Path(".github"))
419424
self.mark_as_new_path(ci_file_folder)
420-
ci_file_folder.mkdir(parents=True, exist_ok=True)
421-
ci_file_path = Path(ci_file_folder) / ci_file_name
422425
self.mark_as_new_path(ci_file_path)
426+
# Creating folder & ci file
427+
ci_file_folder.mkdir(parents=True, exist_ok=True)
423428
download_file_from_url(template_url, ci_file_path)
424429
self.configure_ci_template(ci_file_path)
425430
sc.echo(f"GitHub CI: File was created at {ci_file_path}", formatting=sc.Formats.OKGREEN)
@@ -723,7 +728,11 @@ def choose_push_branch(self) -> None:
723728
]
724729
)
725730
if push_choice == 0:
726-
self.ci_parameters["push_branch"] = sc.answer("Enter target branch: ")
731+
branch = sc.answer("Enter target branch: ")
732+
self.ci_parameters["push_branch"] = branch
733+
sc.echo(f"The HERMES pipeline will be activated when you push on {sc.Formats.BOLD.wrap_around(branch)}",
734+
formatting=sc.Formats.OKGREEN)
735+
sc.echo()
727736
elif push_choice == 1:
728737
sc.echo("Setting up triggering by tags is currently not implemented.", formatting=sc.Formats.WARNING)
729738
sc.echo(f"You can visit {TUTORIAL_URL} to set it up manually later-on.", formatting=sc.Formats.WARNING)
@@ -793,7 +802,10 @@ def clean_up_files(self, aborted: bool) -> None:
793802
This gets called when init is finished (successfully or aborted).
794803
It cleans up unwanted files (like .hermes folder) and everything new when aborted.
795804
"""
796-
os.remove(Path(".hermes"))
805+
sc.echo("Cleaning unused files...")
806+
hidden_hermes_path = Path(".hermes")
807+
if hidden_hermes_path.exists() and hidden_hermes_path.is_dir():
808+
shutil.rmtree(hidden_hermes_path)
797809
if aborted:
798810
if not self.hermes_was_already_installed:
799811
for path in reversed(self.new_created_paths):

src/hermes/commands/init/util/slim_click.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def wrap_around(self, text: str) -> str:
6565
return self.get_ansi() + text + Formats.ENDC.get_ansi()
6666

6767

68-
def echo(text: str, formatting: Formats = Formats.EMPTY, log_as: int = logging.NOTSET, no_log: bool = False):
68+
def echo(text: str = "", formatting: Formats = Formats.EMPTY, log_as: int = logging.NOTSET, no_log: bool = False):
6969
"""
7070
Prints the text with the given formatting. If log_as is set or AUTO_LOG_ON_ECHO is true it gets logged as well.
7171
:param text: The printed text.

0 commit comments

Comments
 (0)