make git optional again

This commit is contained in:
Jörg Thalheim
2023-09-22 16:03:14 +02:00
parent e2cf3c1601
commit e3b2424d9d
4 changed files with 14 additions and 6 deletions

View File

@@ -13,9 +13,10 @@ def commit_file(
repo_dir: Optional[Path] = None,
commit_message: Optional[str] = None,
) -> None:
# set default for repo_dir
if repo_dir is None:
repo_dir = find_git_repo_root()
if repo_dir is None:
return
# check that the file is in the git repository and exists
if not Path(file_path).resolve().is_relative_to(repo_dir.resolve()):
raise ClanError(f"File {file_path} is not in the git repository {repo_dir}")