Skip to content

fix: Detect non-standard default branch names#1336

Merged
charlesvien merged 3 commits intomainfrom
03-26-detect_non-standard_default_branch_names
Mar 30, 2026
Merged

fix: Detect non-standard default branch names#1336
charlesvien merged 3 commits intomainfrom
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

@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
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch 2 times, most recently from 47d5494 to e5d8a2b Compare March 30, 2026 14:45
@charlesvien charlesvien force-pushed the 03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selection branch from d90518c to 84055ab Compare March 30, 2026 14:45
Copy link
Copy Markdown
Member Author

charlesvien commented Mar 30, 2026

Merge activity

  • Mar 30, 2:57 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 30, 3:09 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 30, 3:18 PM UTC: @charlesvien merged this pull request with Graphite.

@charlesvien charlesvien changed the base branch from 03-26-add_prompt_history_to_task_input_and_fix_command_center_text_selection to graphite-base/1336 March 30, 2026 14:59
@charlesvien charlesvien changed the base branch from graphite-base/1336 to main March 30, 2026 15:07
@charlesvien charlesvien force-pushed the 03-26-detect_non-standard_default_branch_names branch from e5d8a2b to 34fecfc Compare March 30, 2026 15:08
@charlesvien charlesvien merged commit fea81ba into main Mar 30, 2026
16 checks passed
@charlesvien charlesvien deleted the 03-26-detect_non-standard_default_branch_names branch March 30, 2026 15:18
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.

2 participants