Files
vibe-kanban/backend
Louis Knight-Webb 31446b96e1 Create task in new repo error (vibe-kanban) (#74)
* Fixed the Git UnbornBranch error that occurs when creating tasks in new repositories without commits. The error was happening in [`TaskAttempt::get_diff`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vk-a98d-create-tas/backend/src/models/task_attempt.rs#L1186) when trying to access the main branch. Added proper error handling to return an empty diff for new repositories.

* Perfect! You were absolutely right. The proper fix was to create an initial commit and main branch when the repository is new, rather than just returning an empty diff. 

The fix now:
1. Detects when a repository has no commits (UnbornBranch error)
2. Creates an initial empty commit on the main branch
3. Sets HEAD to point to the main branch
4. Allows the normal branch creation workflow to proceed

This ensures that task attempts can be created properly in new repositories by establishing the base branch structure they need to work with.

* Perfect! I've updated the code to use the proper Git signature approach:

1. **Primary approach**: Use `repo.signature()` which gets the signature from the Git config (user's name and email)
2. **Fallback**: If no Git config is set, fall back to a default "Vibe Kanban" signature

This ensures that:
- When a user has Git configured, their commits will be properly attributed to them
- When Git is not configured (fresh repository), it falls back to a sensible default
- All other places in the codebase already use `repo.signature()` consistently

The fix now properly handles new repositories by creating an initial commit with the right signature, allowing the normal task creation workflow to proceed.

* fmt
2025-07-04 14:27:25 +01:00
..
2025-07-01 10:03:43 +01:00
2025-07-04 11:11:45 +02:00