File tree Expand file tree Collapse file tree 1 file changed +36
-15
lines changed
Expand file tree Collapse file tree 1 file changed +36
-15
lines changed Original file line number Diff line number Diff line change @@ -79,36 +79,57 @@ export function registerVersionHandlers() {
7979 return [ ] ;
8080 }
8181
82- // Determine the current ref dynamically (main, master , or current branch )
83- let currentRef = "main" ;
82+ // Determine the current ref dynamically (current branch, main , or master )
83+ let currentRef : string ;
8484 try {
85- await git . resolveRef ( {
85+ // First, try to get the current branch
86+ const currentBranch = await git . currentBranch ( {
8687 fs,
8788 dir : appPath ,
88- ref : "main" ,
89+ fullname : false ,
8990 } ) ;
91+ if ( currentBranch ) {
92+ currentRef = currentBranch ;
93+ } else {
94+ // If no current branch (detached HEAD), try main
95+ try {
96+ await git . resolveRef ( {
97+ fs,
98+ dir : appPath ,
99+ ref : "main" ,
100+ } ) ;
101+ currentRef = "main" ;
102+ } catch {
103+ // Try master branch if main doesn't exist
104+ try {
105+ await git . resolveRef ( {
106+ fs,
107+ dir : appPath ,
108+ ref : "master" ,
109+ } ) ;
110+ currentRef = "master" ;
111+ } catch {
112+ throw new Error ( "Could not resolve any branch reference" ) ;
113+ }
114+ }
115+ }
90116 } catch {
91- // Try master branch if main doesn't exist
117+ // Fallback: try main, then master
92118 try {
93119 await git . resolveRef ( {
94120 fs,
95121 dir : appPath ,
96- ref : "master " ,
122+ ref : "main " ,
97123 } ) ;
98- currentRef = "master " ;
124+ currentRef = "main " ;
99125 } catch {
100- // Try to get current branch name
101126 try {
102- const currentBranch = await git . currentBranch ( {
127+ await git . resolveRef ( {
103128 fs,
104129 dir : appPath ,
105- fullname : false ,
130+ ref : "master" ,
106131 } ) ;
107- if ( currentBranch ) {
108- currentRef = currentBranch ;
109- } else {
110- throw new Error ( "Could not determine current branch" ) ;
111- }
132+ currentRef = "master" ;
112133 } catch {
113134 throw new Error ( "Could not resolve any branch reference" ) ;
114135 }
You can’t perform that action at this time.
0 commit comments