Skip to content

Initialize Git repositories on crewai create ...#6364

Merged
vinibrsl merged 1 commit into
mainfrom
codex/initialize-git-repos-on-create
Jun 26, 2026
Merged

Initialize Git repositories on crewai create ...#6364
vinibrsl merged 1 commit into
mainfrom
codex/initialize-git-repos-on-create

Conversation

@vinibrsl

@vinibrsl vinibrsl commented Jun 26, 2026

Copy link
Copy Markdown
Member

Initialize a Git repo when crewai create crew, crewai create flow, and JSON crew creation finish successfully.


Note

Low Risk
Scoped CLI scaffolding change that no-ops when Git is missing; only runs git init on new project directories.

Overview
Newly scaffolded crew, flow, and JSON crew projects now run git init at the end of creation when Git is on the PATH, via a shared initialize_if_git_available helper in crewai_cli.git.

Python crew creation only does this for top-level projects (not parent_folder), so crews added inside an existing flow folder are unchanged. Flow and JSON crew paths always init Git on the new project root after templates and env setup.

Tests add an integration check that crewai create crew and crewai create flow leave a .git directory when Git is installed, and mocked crew tests now create the mock folder on disk so scaffolding matches real behavior.

Reviewed by Cursor Bugbot for commit 74f8c3c. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Newly created crew, flow, and JSON crew projects now initialize Git automatically when Git is available, so generated projects are ready for versioning.
  • Tests
    • Added CLI coverage to verify Git initialization for crew and flow generation when Git is available.
    • Updated existing creation tests to ensure the target project directories exist before scaffolding assertions.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c78d97d-7d03-46ee-9f34-ec685b8a3348

📥 Commits

Reviewing files that changed from the base of the PR and between 20433b9 and 74f8c3c.

📒 Files selected for processing (5)
  • lib/cli/src/crewai_cli/create_crew.py
  • lib/cli/src/crewai_cli/create_flow.py
  • lib/cli/src/crewai_cli/create_json_crew.py
  • lib/cli/src/crewai_cli/git.py
  • lib/cli/tests/test_create_crew.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/cli/src/crewai_cli/create_flow.py
  • lib/cli/src/crewai_cli/create_json_crew.py
  • lib/cli/src/crewai_cli/create_crew.py
  • lib/cli/tests/test_create_crew.py

📝 Walkthrough

Walkthrough

Crew, flow, and JSON crew scaffolding now initialize a Git repository in the generated project root when Git is available. A new helper centralizes the Git check and initialization path, and tests cover the updated CLI behavior.

Changes

CLI Git initialization

Layer / File(s) Summary
Git init helper
lib/cli/src/crewai_cli/git.py
Adds initialize_if_git_available, which checks Repository.is_git_installed() and runs git init in the target path when Git is available.
Scaffold commands
lib/cli/src/crewai_cli/create_crew.py, lib/cli/src/crewai_cli/create_flow.py, lib/cli/src/crewai_cli/create_json_crew.py
Imports initialize_if_git_available in the crew, flow, and JSON crew generators and invokes it after project files are created.
CLI tests
lib/cli/tests/test_create_crew.py
Adds the CLI entrypoint import, creates mocked project directories before direct create_crew calls, and adds a git-guarded CLI test that checks for a .git directory.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: automatically initializing Git for scaffolding commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/initialize-git-repos-on-create

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vinibrsl vinibrsl marked this pull request as ready for review June 26, 2026 23:05

@corridor-security corridor-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: This PR initializes a Git repository after successful project generation for crews, flows, and JSON crews. No exploitable security vulnerabilities were identified in the added code.

Risk: Low risk. The new subprocess invocation uses a fixed argument list without shell execution and does not introduce public endpoints, authentication changes, or new data-access boundaries.

@vinibrsl vinibrsl changed the title Initialize Git repositories for generated projects Initialize Git repositories on crewai create ... Jun 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/cli/src/crewai_cli/git.py`:
- Around line 206-212: The initialize_if_git_available helper currently lets
subprocess.run(["git", "init"], check=True) raise and crash the CLI even after
scaffolding is complete. Update initialize_if_git_available to treat git init as
best-effort: catch the failure from subprocess.run in this function, optionally
emit a warning, and return False instead of propagating the exception. Keep the
existing Repository.is_git_installed guard and preserve the True return only
when git init succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a4712ead-9e99-4d2f-9b0d-b9beb340b767

📥 Commits

Reviewing files that changed from the base of the PR and between e716f3d and 20433b9.

📒 Files selected for processing (5)
  • lib/cli/src/crewai_cli/create_crew.py
  • lib/cli/src/crewai_cli/create_flow.py
  • lib/cli/src/crewai_cli/create_json_crew.py
  • lib/cli/src/crewai_cli/git.py
  • lib/cli/tests/test_create_crew.py

Comment thread lib/cli/src/crewai_cli/git.py
@vinibrsl vinibrsl force-pushed the codex/initialize-git-repos-on-create branch from 20433b9 to 74f8c3c Compare June 26, 2026 23:20

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 74f8c3c. Configure here.

Comment thread lib/cli/src/crewai_cli/git.py
@vinibrsl vinibrsl merged commit e1ddb32 into main Jun 26, 2026
56 checks passed
@vinibrsl vinibrsl deleted the codex/initialize-git-repos-on-create branch June 26, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants