From 331965f0afac6108735ee5f0659db9fc9ce52305 Mon Sep 17 00:00:00 2001 From: Simon Halvorsen Date: Wed, 22 Jul 2026 11:51:36 +0200 Subject: [PATCH] ENT-14302: Added a check for .git-dir inside masterfiles-* when using`cfbs convert` to avoid crashing Ticket: ENT-14302 Signed-off-by: Simon Halvorsen --- cfbs/commands.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cfbs/commands.py b/cfbs/commands.py index 81429111..ce92368b 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -1225,6 +1225,15 @@ def cfbs_convert_git_commit( dir_name = dir_content[0] path_string = "./" + dir_name + "/" + has_gitfolder = os.path.isdir(os.path.join(path_string, ".git")) + if has_gitfolder: + print( + "A `.git`-directory already exists inside %s and it will not be possible to initialize a cfbs-project" + % path_string + ) + if not prompt_user_yesno(non_interactive, "Do you want to remove this?"): + raise CFBSExitError("`.git`-directory was not removed, exiting.") + rm(os.path.join(path_string, ".git")) # validate the local module validate_module_name_content(path_string) @@ -1282,6 +1291,7 @@ def cfbs_convert_git_commit( print("Initializing a new CFBS project...") # since there should be no other files than the masterfiles-name directory, there shouldn't be a .git directory assert not is_git_repo() + assert not is_git_repo(path_string) try: r = init_command( masterfiles="no", non_interactive=non_interactive, use_git=True