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

Modify default kwargs based on internal testing

parent 01fc4aab
No related branches found
No related tags found
No related merge requests found
...@@ -55,13 +55,13 @@ def is_tool(name): ...@@ -55,13 +55,13 @@ def is_tool(name):
@click.command() @click.command()
@click.option('--output_repo_name', default="output", @click.option('--output_repo_name', default="output",
help='Name of the folder where the tracked output should be stored.') help='Name of the folder where the tracked output should be stored. Optional. Default: "output".')
@click.option('--gitignore', default=None, @click.option('--gitignore', default=None,
help='List of files to be added to the gitignore file.') help='List of files to be added to the gitignore file. Optional.')
@click.option('--gitattributes', default=None, @click.option('--gitattributes', default=None,
help='List of files to be added to the gitattributes file.') help='List of files to be added to the gitattributes file. Optional.')
@click.option('--lfs_filetypes', default=None, @click.option('--lfs_filetypes', default=None,
help='List of filetypes to be handled by git lfs.') help='List of filetypes to be handled by git lfs. Optional.')
@click.argument('path_to_repo') @click.argument('path_to_repo')
def initialize_git_repo_cli(path_to_repo: str, output_repo_name: (str | bool) = "output", gitignore: list = None, def initialize_git_repo_cli(path_to_repo: str, output_repo_name: (str | bool) = "output", gitignore: list = None,
gitattributes: list = None, lfs_filetypes: list = None, gitattributes: list = None, lfs_filetypes: list = None,
......
...@@ -261,7 +261,8 @@ class BaseRepo: ...@@ -261,7 +261,8 @@ class BaseRepo:
class ProjectRepo(BaseRepo): class ProjectRepo(BaseRepo):
def __init__(self, repository_path=None, output_folder=None, *args, **kwargs): def __init__(self, repository_path=None, output_folder=None,
search_parent_directories=True, *args, **kwargs):
""" """
Class for Project-Repositories. Handles interaction between the project repo and Class for Project-Repositories. Handles interaction between the project repo and
the output (i.e. results) repo. the output (i.e. results) repo.
...@@ -270,13 +271,18 @@ class ProjectRepo(BaseRepo): ...@@ -270,13 +271,18 @@ class ProjectRepo(BaseRepo):
Path to the root of the git repository. Path to the root of the git repository.
:param output_folder: :param output_folder:
Path to the root of the output repository. Path to the root of the output repository.
:param search_parent_directories:
if True, all parent directories will be searched for a valid repo as well.
Please note that this was the default behaviour in older versions of GitPython,
which is considered a bug though.
:param args: :param args:
Additional args to be handed to BaseRepo. Additional args to be handed to BaseRepo.
:param kwargs: :param kwargs:
Additional kwargs to be handed to BaseRepo. Additional kwargs to be handed to BaseRepo.
""" """
super().__init__(repository_path, *args, **kwargs) super().__init__(repository_path, search_parent_directories=search_parent_directories, *args, **kwargs)
if output_folder is not None: if output_folder is not None:
self._output_folder = output_folder self._output_folder = output_folder
...@@ -475,13 +481,17 @@ class ProjectRepo(BaseRepo): ...@@ -475,13 +481,17 @@ class ProjectRepo(BaseRepo):
self.remove_cached_files() self.remove_cached_files()
@contextlib.contextmanager @contextlib.contextmanager
def track_results(self, results_commit_message: str): def track_results(self, results_commit_message: str, debug=False):
""" """
Context manager to be used when runnning project code that produces output that should Context manager to be used when running project code that produces output that should
be tracked in the output repository. be tracked in the output repository.
:param results_commit_message: :param results_commit_message:
Commit message for the commit of the output repository. Commit message for the commit of the output repository.
""" """
if debug:
yield "debug"
return
new_branch_name = self.enter_context() new_branch_name = self.enter_context()
try: try:
yield new_branch_name yield new_branch_name
......
[metadata] [metadata]
name = modsimdata name = CADETRDM
version = 0.1.0 version = 0.1.0
author = Ronald Jäpel author = Ronald Jäpel
author_email = r.jaepel@fz-juelich.de author_email = r.jaepel@fz-juelich.de
......
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