Create a local initial commit when the repository has no commits.
(self)
| 161 | return bool(result.stdout.strip()) |
| 162 | |
| 163 | def create_initial_commit_if_needed(self) -> bool: |
| 164 | """Create a local initial commit when the repository has no commits.""" |
| 165 | if self.has_commits(): |
| 166 | return False |
| 167 | |
| 168 | self._ensure_initial_commit_excludes() |
| 169 | subprocess.run(["git", "add", "."], cwd=self.path, check=True) # noqa: S607 |
| 170 | command = [ |
| 171 | "git", |
| 172 | "-c", |
| 173 | "user.name=CrewAI", |
| 174 | "-c", |
| 175 | "user.email=deploy@crewai.com", |
| 176 | "commit", |
| 177 | "--allow-empty", |
| 178 | "-m", |
| 179 | "Initial crew", |
| 180 | ] |
| 181 | subprocess.run( # noqa: S603 |
| 182 | command, |
| 183 | cwd=self.path, |
| 184 | check=True, |
| 185 | ) |
| 186 | return True |
| 187 | |
| 188 | def _ensure_initial_commit_excludes(self) -> None: |
| 189 | """Add local-only ignore patterns before auto-staging an initial commit.""" |
no test coverage detected