Skip to content

fix(tauri,core): auto-detect default branch when adding a repository#7

Merged
Ghvstcode merged 1 commit intomainfrom
fix-default-branch-detection
Mar 26, 2026
Merged

fix(tauri,core): auto-detect default branch when adding a repository#7
Ghvstcode merged 1 commit intomainfrom
fix-default-branch-detection

Conversation

@Ghvstcode
Copy link
Copy Markdown
Owner

Previously, default_branch was stored as NULL when a repo was added, falling back to the hardcoded string "main". If the repo used "master" or any other branch name, the engine worker would fail when trying to create a task branch with: "fatal: 'main' is not a commit and a branch '...' cannot be created from it."

  • Add detect_default_branch() to engine/git.rs: tries git symbolic-ref --short refs/remotes/origin/HEAD first (accurate for cloned repos with a remote), falls back to current branch name, then "main" as a last resort
  • Add get_repo_default_branch Tauri command in repository.rs and register it in lib.rs
  • Update addRepository() in repositories.ts to call the new command and store the detected branch in the INSERT statement
  • Remove the duplicate (and less accurate) branch detection that was running in useAddRepository after dbAddRepository

Existing repos with NULL/incorrect default_branch can be corrected via the repository settings UI.

Previously, default_branch was stored as NULL when a repo was added,
falling back to the hardcoded string "main". If the repo used "master"
or any other branch name, the engine worker would fail when trying to
create a task branch with: "fatal: 'main' is not a commit and a branch
'...' cannot be created from it."

- Add detect_default_branch() to engine/git.rs: tries
  `git symbolic-ref --short refs/remotes/origin/HEAD` first (accurate
  for cloned repos with a remote), falls back to current branch name,
  then "main" as a last resort
- Add get_repo_default_branch Tauri command in repository.rs and
  register it in lib.rs
- Update addRepository() in repositories.ts to call the new command
  and store the detected branch in the INSERT statement
- Remove the duplicate (and less accurate) branch detection that was
  running in useAddRepository after dbAddRepository

Existing repos with NULL/incorrect default_branch can be corrected via
the repository settings UI.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sustn Ready Ready Preview, Comment Mar 24, 2026 6:44am

@Ghvstcode Ghvstcode merged commit af3a2f7 into main Mar 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant