From 443939affddb98c424f8ebdd03dd15acf399f547 Mon Sep 17 00:00:00 2001 From: "r.jaepel" <r.jaepel@fz-juelich.de> Date: Wed, 9 Aug 2023 13:41:10 +0200 Subject: [PATCH] update add_all_files --- git_lfs_utils/utils.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/git_lfs_utils/utils.py b/git_lfs_utils/utils.py index 0dabd02..c0f3b26 100644 --- a/git_lfs_utils/utils.py +++ b/git_lfs_utils/utils.py @@ -30,16 +30,24 @@ class GitRepo(git.Repo): # This means that root was reached without finding a git repo. raise ValueError(f"Path {starting_path} does not contain a git repository.") - def add_all_files(self): + def add_all_files(self, automatically_add_new_files=True): if len(self.untracked_files) > 0: untracked_files = "\n".join(["- " + file for file in self.untracked_files]) - proceed = input(f'Found untracked files. Adding the following untracked files to git: \n{untracked_files}\n' - f'Proceed? Y/n \n') + + if automatically_add_new_files: + for f in self.untracked_files: + self.git.add(f) + else: + proceed = input( + f'Found untracked files. Adding the following untracked files to git: \n{untracked_files}\n' + f'Proceed? Y/n \n' + ) if proceed.lower() == "y" or proceed == "": for f in self.untracked_files: self.git.add(f) else: raise KeyboardInterrupt + changed_files = self.git.diff(None, name_only=True).split('\n') if "" in changed_files: changed_files.remove("") -- GitLab