Skip to content
Snippets Groups Projects
Commit e46a5b81 authored by Attila Farkas's avatar Attila Farkas
Browse files

Remove .git directory after cloning a repository

parent f2a8c095
No related branches found
No related tags found
2 merge requests!35Version 2.0.0,!33Remove .git directory after cloning a repository
......@@ -70,9 +70,11 @@ class Preconfig:
sandbox.config["preconfig_dir"])
Writer.clone_git_repository(sandbox.config["common_repo"],
sandbox.sandbox_dir / sandbox.config["preconfig_roles"])
sandbox.sandbox_dir / sandbox.config["preconfig_roles"],
sandbox.config["common_role"])
Writer.clone_git_repository(sandbox.config["interface_repo"],
sandbox.sandbox_dir / sandbox.config["preconfig_roles"])
sandbox.sandbox_dir / sandbox.config["preconfig_roles"],
sandbox.config["interface_role"])
host_vars: Dict[str, Dict] = Preconfig._create_host_vars(sandbox)
for host, variables in host_vars.items():
......
......@@ -62,11 +62,12 @@ class Writer:
Writer._write_to_file(output_file, output)
@staticmethod
def clone_git_repository(repository: str, location: Path) -> None:
"""Clone a git repository to the provided location
def clone_git_repository(repository: str, location: Path, cloned_dir: str) -> None:
"""Clone a git repository to the provided location and removes .git
:param repository: repository location
:param location: target directory
:param cloned_dir: name of the cloned directory
"""
try:
......@@ -76,6 +77,11 @@ class Writer:
except RuntimeError:
raise RuntimeError(f"Could not clone repository: {repository}")
try:
shutil.rmtree(location.joinpath(cloned_dir).joinpath(".git"))
except OSError:
pass
@staticmethod
def copy_file(source: Path, destination: Path):
"""Copies a file from the source path to the destination
......
......@@ -35,5 +35,7 @@ provisioning_inventory: provisioning/hosts.yml
user_extra_vars: provisioning/extra_vars.yml
#Git repositories
common_role: common
common_repo: https://gitlab.ics.muni.cz/CSIRT-MU-PUBLIC/ansible-roles/common.git
interface_role: interface
interface_repo: https://gitlab.ics.muni.cz/CSIRT-MU-PUBLIC/ansible-roles/interface.git
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment