File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,6 +85,24 @@ async function main() {
8585 await $ `git commit -m ${ commitMessage } `
8686 console . log ( `✅ Changes committed` )
8787
88+ // Delete any existing branches for opencode updates
89+ console . log ( `🔍 Checking for existing branches...` )
90+ const branches = await $ `git ls-remote --heads https://x-access-token:${ token } @github.com/${ FORK_REPO } .git` . text ( )
91+ const branchPattern = `refs/heads/update-${ EXTENSION_NAME } -`
92+ const oldBranches = branches
93+ . split ( "\n" )
94+ . filter ( ( line ) => line . includes ( branchPattern ) )
95+ . map ( ( line ) => line . split ( "refs/heads/" ) [ 1 ] )
96+ . filter ( Boolean )
97+
98+ if ( oldBranches . length > 0 ) {
99+ console . log ( `🗑️ Found ${ oldBranches . length } old branch(es), deleting...` )
100+ for ( const branch of oldBranches ) {
101+ await $ `git push https://x-access-token:${ token } @github.com/${ FORK_REPO } .git --delete ${ branch } `
102+ console . log ( `✅ Deleted branch ${ branch } ` )
103+ }
104+ }
105+
88106 console . log ( `🚀 Pushing to fork...` )
89107 await $ `git push https://x-access-token:${ token } @github.com/${ FORK_REPO } .git ${ branchName } `
90108
You can’t perform that action at this time.
0 commit comments