MCPcopy Create free account
hub / github.com/crewAIInc/crewAI / create_initial_commit_if_needed

Method create_initial_commit_if_needed

lib/cli/src/crewai_cli/git.py:163–186  ·  view source on GitHub ↗

Create a local initial commit when the repository has no commits.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers 2

initializeMethod · 0.80

Calls 3

has_commitsMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected