Skip to content
Snippets Groups Projects
Commit 9c40d69f authored by Ronald Jäpel's avatar Ronald Jäpel
Browse files

Rname CLI clone functionality

parent e43a121f
No related branches found
No related tags found
No related merge requests found
......@@ -152,3 +152,11 @@ You can use this file to load the remote repositories based on the cache.json wi
```bash
cadet-rdm fill-data-from-cadet-rdm-json
```
### Cloning from remote
You should use `cadet-rdm clone` instead of `git clone` to clone the repo to a new location.
```bash
cadet-rdm clone <URL> <path/to/repo>
```
from .repositories import ProjectRepo
from .initialize_repo import initialize_repo, initialize_from_remote
from .initialize_repo import initialize_repo, clone
from .conda_env_utils import prepare_conda_env
__version__ = "0.0.6"
......@@ -5,7 +5,7 @@ import click
from .repositories import ProjectRepo, BaseRepo
from .initialize_repo import initialize_repo as initialize_git_repo_implementation, init_lfs
from .initialize_repo import initialize_from_remote as initialize_from_remote_implementation
from .initialize_repo import clone as clone_implementation
from .conda_env_utils import prepare_conda_env as prepare_conda_env_implementation
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
......@@ -20,8 +20,8 @@ def cli():
@click.option('--path_to_repo', default=None,
help='Path to folder for the repository. Optional.')
@click.argument('project_url')
def initialize_from_remote(project_url, path_to_repo: str = None):
initialize_from_remote_implementation(project_url, path_to_repo)
def clone(project_url, path_to_repo: str = None):
clone_implementation(project_url, path_to_repo)
@cli.command()
......
......@@ -168,7 +168,7 @@ def create_output_readme():
write_lines_to_file("README.md", readme_lines, open_type="a")
def initialize_from_remote(project_url, path_to_repo: str = None):
def clone(project_url, path_to_repo: str = None):
if path_to_repo is None:
path_to_repo = project_url.split("/")[-1]
print(f"Cloning {project_url} into {path_to_repo}")
......@@ -192,5 +192,8 @@ def initialize_from_remote(project_url, path_to_repo: str = None):
break
environment_path = os.path.join(os.getcwd(), path_to_repo, "environment.yml")
repo = ProjectRepo(path_to_repo)
repo.fill_data_from_cadet_rdm_json()
print("To set up the project conda environment please run this command:\n"
f"conda deactivate && conda env create -f '{environment_path}'")
......@@ -7,7 +7,7 @@ import pytest
import git
import numpy as np
from cadetrdm import initialize_repo, ProjectRepo, initialize_from_remote
from cadetrdm import initialize_repo, ProjectRepo, clone
from cadetrdm.initialize_repo import init_lfs
from cadetrdm.repositories import OutputRepo, BaseRepo
from cadetrdm.io_utils import delete_path
......@@ -134,7 +134,7 @@ def try_add_remote(path_to_repo):
def try_initialize_from_remote():
if os.path.exists("test_repo_from_remote"):
delete_path("test_repo_from_remote")
initialize_from_remote("https://jugit.fz-juelich.de/IBG-1/ModSim/cadet/rdm-examples-fraunhofer-ime-aachen",
clone("https://jugit.fz-juelich.de/IBG-1/ModSim/cadet/rdm-examples-fraunhofer-ime-aachen",
"test_repo_from_remote")
assert try_init_gitpython_repo("test_repo_from_remote")
......
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