Initialize a Git repository and create an initial commit if needed.
(cls, path: str = ".")
| 72 | |
| 73 | @classmethod |
| 74 | def initialize(cls, path: str = ".") -> Repository: |
| 75 | """Initialize a Git repository and create an initial commit if needed.""" |
| 76 | if not cls.is_git_installed(): |
| 77 | raise ValueError("Git is not installed or not found in your PATH.") |
| 78 | |
| 79 | subprocess.run(["git", "init"], cwd=path, check=True) # noqa: S607 |
| 80 | repository = cls(path=path, fetch=False) |
| 81 | repository.create_initial_commit_if_needed() |
| 82 | return repository |
| 83 | |
| 84 | def status(self) -> str: |
| 85 | """Get the git status in porcelain format.""" |