Skip to content

fix: Detect non-standard default branch names#1336

Open
charlesvien wants to merge 1 commit into03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selectionfrom
03-26-detect_non-standard_default_branch_names
Open

fix: Detect non-standard default branch names#1336
charlesvien wants to merge 1 commit into03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selectionfrom
03-26-detect_non-standard_default_branch_names

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented Mar 26, 2026

Problem

Git setup fails with fatal: invalid reference main when a repo's default branch isn't main or master, because detection only checked those two names and callers silently fell back to hardcoded "main".

Changes

  1. Add init.defaultBranch config and current HEAD as fallbacks in detectDefaultBranch()
  2. Fix detectDefaultBranchWithFallback() to try HEAD before hardcoding "main"
  3. Fix workspace service .catch(() => "main") to use current branch
  4. Fix git service GitHub API fallback to return empty instead of guessing "main"
  5. Add unit tests for all default branch detection strategies

How did you test this?

Manually + added unit tests

@charlesvien charlesvien changed the title Detect non-standard default branch names fix: Detect non-standard default branch names Mar 26, 2026
Copy link
Copy Markdown
Member Author

charlesvien commented Mar 26, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien marked this pull request as ready for review March 26, 2026 09:47
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch 2 times, most recently from 23e11af to b99d30b Compare March 26, 2026 10:49
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch from b99d30b to a01c096 Compare March 28, 2026 12:37
@charlesvien charlesvien force-pushed the 03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selection branch from a0ab153 to 6e486a5 Compare March 28, 2026 18:32
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch from a01c096 to 32623d4 Compare March 28, 2026 18:32
@charlesvien charlesvien mentioned this pull request Mar 28, 2026
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch from 32623d4 to e9fe4ae Compare March 29, 2026 08:59
@charlesvien charlesvien force-pushed the 03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selection branch from 6e486a5 to 4db14f5 Compare March 29, 2026 08:59
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