From 43c35248df0da71e2078ec19678bd4d2c5212215 Mon Sep 17 00:00:00 2001 From: Hannah Lanzrath Date: Wed, 11 Feb 2026 16:49:04 +0100 Subject: [PATCH 1/5] Feat: expose git add to CLI This commit exposes the git add function to the CLI via "rdm add" which allows specifying files to be staged. --- cadetrdm/cli_integration.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cadetrdm/cli_integration.py b/cadetrdm/cli_integration.py index edf9105..82c413f 100644 --- a/cadetrdm/cli_integration.py +++ b/cadetrdm/cli_integration.py @@ -90,6 +90,14 @@ def commit(message, all): del repo +@cli.command(help="Stage changes") +@click.argument("filepath", type=click.Path()) +def add(filepath): + from cadetrdm.repositories import ProjectRepo + repo = ProjectRepo(".") + repo.add(filepath) + + @cli.group(help="Execute commands and track the results.") def run(): pass From 59d4a48e62f501db49ccd82ab147380ba4af5f43 Mon Sep 17 00:00:00 2001 From: Hannah Lanzrath Date: Wed, 11 Feb 2026 16:58:08 +0100 Subject: [PATCH 2/5] Set commit argument "add_all" to False per default and remove flag from internal function calls --- cadetrdm/repositories.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cadetrdm/repositories.py b/cadetrdm/repositories.py index 737da93..5a65592 100644 --- a/cadetrdm/repositories.py +++ b/cadetrdm/repositories.py @@ -300,7 +300,7 @@ def remote_set_url(self, name: str, url: str): def commit( self, message: str | None = None, - add_all=True, + add_all=False, verbosity=1, ) -> None: """ @@ -593,7 +593,7 @@ def add_remote(self, remote_url, remote_name=None): output_repo.checkout(output_repo.main_branch) output_repo.add_list_of_remotes_in_readme_file("Link to Project Repository", self.remote_urls) output_repo.add("README.md") - output_repo.commit("Add remote for project repo", verbosity=0, add_all=False) + output_repo.commit("Add remote for project repo", verbosity=0) if self.metadata["is_output_repo"]: # This directory is an output repository. project_repo = ProjectRepo(self.path.parent) @@ -601,7 +601,7 @@ def add_remote(self, remote_url, remote_name=None): project_repo.add_list_of_remotes_in_readme_file("Link to Output Repository", self.remote_urls) project_repo.add(project_repo.data_json_path) project_repo.add("README.md") - project_repo.commit("Add remote for output repo", verbosity=0, add_all=False) + project_repo.commit("Add remote for output repo", verbosity=0) def import_remote_repo(self, source_repo_location, source_repo_branch, target_repo_location=None): """ @@ -1177,13 +1177,13 @@ def check(self, commit=True): """ self.update_output_remotes_json() if commit: - super().commit(message="Update remote links", add_all=False, verbosity=1) + super().commit(message="Update remote links", verbosity=1) # update urls in main branch of output_repo self.output_repo._git.checkout(self.output_repo.main_branch) self.output_repo.add_list_of_remotes_in_readme_file("Link to Project Repository", self.remote_urls) if commit: - self.output_repo.commit(message="Update remote links", add_all=False, verbosity=1) + self.output_repo.commit(message="Update remote links", verbosity=1) def update_output_remotes_json(self, load_metadata=True): output_repo_remotes = self.output_repo.remote_urls @@ -1724,7 +1724,7 @@ def _convert_csv_to_tsv_if_necessary(self) -> None: ) self.add(self.path / "log.csv") self.add(self.path / "log.tsv") - self.commit("Convert csv to tsv", add_all=False) + self.commit("Convert csv to tsv") def _expand_tsv_header(self): """Update tsv header.""" @@ -1750,7 +1750,7 @@ def _expand_tsv_header(self): f.writelines(lines[1:]) self.add(self.output_log_file_path) - self.commit("Update tsv header", add_all=False) + self.commit("Update tsv header") def _update_headers(self): """Update tsv header.""" @@ -1776,7 +1776,7 @@ def _update_headers(self): f.writelines(lines[1:]) self.add(self.output_log_file_path) - self.commit("Update tsv header", add_all=False) + self.commit("Update tsv header") def _fix_gitattributes_log_tsv(self): """Update .gitattributes to account for changed logfile name.""" @@ -1788,7 +1788,7 @@ def _fix_gitattributes_log_tsv(self): handle.writelines(lines) self.add(".gitattributes") - self.commit("Update .gitattributes", add_all=False) + self.commit("Update .gitattributes") def _update_log_hashes(self): if self.has_uncomitted_changes: @@ -1813,7 +1813,7 @@ def _update_log_hashes(self): log.write() self.add(self.output_log_file_path) - self.commit(message="Updated log hashes", add_all=False) + self.commit(message="Updated log hashes") def _rename_project_repo_folder_to_directory_in_log(self) -> None: """Rename the TSV column header from folder to directory.""" @@ -1902,7 +1902,7 @@ def _add_branch_name_to_log(self) -> None: class JupyterInterfaceRepo(ProjectRepo): - def commit(self, message: str | None = None, add_all=True, verbosity=1): + def commit(self, message: str | None = None, add_all=False, verbosity=1): """ Commit current state of the repository. From 74df4bf321df1258270c608f479850ce14f3b494 Mon Sep 17 00:00:00 2001 From: Hannah Lanzrath Date: Wed, 11 Feb 2026 17:05:58 +0100 Subject: [PATCH 3/5] Docs: Update staging and commiting section in CLI documentation --- docs/source/user_guide/command-line-interface.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/source/user_guide/command-line-interface.md b/docs/source/user_guide/command-line-interface.md index 1b645ee..695d247 100644 --- a/docs/source/user_guide/command-line-interface.md +++ b/docs/source/user_guide/command-line-interface.md @@ -52,16 +52,22 @@ The command must be enclosed in quotes. ### Staging, committing, and pushing changes -Check repository consistency and stage changes: +Check repository consistency: ```bash rdm check ``` -Commit staged changes: +Stage changes: ```bash -rdm commit -m +rdm add +``` + +Commit staged changes (option: setting `-a` will stage all changes and commit them): + +```bash +rdm commit -m [-a] ``` Push both project and output repositories: From 92c9ebb6a342146ebef8b779fa28daa7650a7041 Mon Sep 17 00:00:00 2001 From: Hannah Lanzrath Date: Wed, 11 Feb 2026 17:10:19 +0100 Subject: [PATCH 4/5] Docs: Update staging and committing section with repo.add and optional add_all flag in PI documentation --- docs/source/user_guide/python-interface.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/user_guide/python-interface.md b/docs/source/user_guide/python-interface.md index f3e47ee..9526fed 100644 --- a/docs/source/user_guide/python-interface.md +++ b/docs/source/user_guide/python-interface.md @@ -45,8 +45,12 @@ Results are tracked using the `ProjectRepo` interface. All files written inside from cadetrdm import ProjectRepo repo = ProjectRepo() +repo.add(path_to_changed_file) repo.commit("Commit code changes") +``` +Optionally, the argument `add_all=True` can be given to `repo.commit()` to stage all changed files and commit them instead of using the preceding `repo.add()`. +```python with repo.track_results(results_commit_message="Generate results"): data = generate_data() write_data_to_file(data, output_directory=repo.output_directory) From 62ae9ff0fe7eae8f63f31141d3268d41be00132b Mon Sep 17 00:00:00 2001 From: Hannah Lanzrath Date: Wed, 11 Feb 2026 17:44:04 +0100 Subject: [PATCH 5/5] Set add_all=True in initialize repo --- cadetrdm/initialize_repo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadetrdm/initialize_repo.py b/cadetrdm/initialize_repo.py index 683c26f..c2833f3 100644 --- a/cadetrdm/initialize_repo.py +++ b/cadetrdm/initialize_repo.py @@ -224,7 +224,7 @@ def initialize_output_repo(output_directory_name, gitignore: list = None, create_output_readme() repo = OutputRepo(".") - repo.commit("initial commit") + repo.commit("initial commit", add_all=True) os.chdir(starting_directory)