@@ -20,49 +20,38 @@ async function runGitCommands() {
2020 // Get branch name from command line arguments or use default
2121 const branchName = process . argv [ 2 ] || 'stable-main' ;
2222
23- // Get base stable branch from environment variable (defaults to 'master ' for backward compatibility of extension )
24- const baseBranch = process . env . BASE_BRANCH || 'master ' ;
23+ // Get base stable branch from environment variable (defaults to 'stable ' for backward compatibility for mobile )
24+ const baseBranch = process . env . BASE_BRANCH || 'stable ' ;
2525
2626 // Check if CREATE_BRANCH environment variable exists and is set to true
2727 const shouldPushBranch = ( process . env . CREATE_BRANCH || 'false' ) . toLowerCase ( ) === 'true' ;
2828
2929 try {
3030 try {
3131 // Check if the branch already exists
32- const { stdout : branchExists } = await exec (
33- //`git rev-parse --quiet --verify ${branchName}`,
34- `git ls-remote origin ${ branchName } ` ,
35- ) ;
32+ const { stdout : branchExists } = await exec ( `git ls-remote origin ${ branchName } ` ) ;
3633 if ( branchExists . trim ( ) ) {
37- // Branch exists, so simply check it out
34+ // Branch exists, check it out
3835 await exec ( `git checkout ${ branchName } ` ) ;
3936 await exec ( `git pull origin ${ branchName } ` ) ;
4037 console . log ( `Checked out branch: ${ branchName } ` ) ;
4138 } else {
42- throw new Error (
43- 'git rev-parse --quiet --verify failed. Branch hash empty' ,
44- ) ;
45- }
46- } catch ( error ) {
47- if ( error . stdout === '' ) {
48- console . warn (
49- `Branch does not exist, creating new ${ branchName } branch.` ,
50- ) ;
51-
52- // Branch does not exist, create and check it out
39+ // Branch doesn't exist, create it
40+ console . warn ( `Branch does not exist, creating new ${ branchName } branch.` ) ;
5341 await exec ( `git checkout -b ${ branchName } ` ) ;
5442 console . log ( `Created and checked out branch: ${ branchName } ` ) ;
55- } else {
56- console . error ( `Error: ${ error . message } ` ) ;
57- process . exit ( 1 ) ;
5843 }
44+ } catch ( error ) {
45+ // Handle actual git command errors
46+ console . error ( `Error: ${ error . message } ` ) ;
47+ process . exit ( 1 ) ;
5948 }
6049
6150 await exec ( 'git fetch' ) ;
6251 console . log ( 'Executed: git fetch' ) ;
6352
64- await exec ( ' git reset --hard origin/stable' ) ;
65- console . log ( ' Executed: git reset --hard origin/stable' ) ;
53+ await exec ( ` git reset --hard origin/${ baseBranch } ` ) ;
54+ console . log ( ` Executed: git reset --hard origin/${ baseBranch } ` ) ;
6655
6756 try {
6857 await exec ( 'git merge origin/main' ) ;
@@ -90,31 +79,31 @@ async function runGitCommands() {
9079 await exec ( 'git checkout origin/main -- .' ) ;
9180 console . log ( 'Executed: git checkout origin/main -- .' ) ;
9281
93- await exec ( ' git checkout origin/stable -- CHANGELOG.md' ) ;
94- console . log ( ' Executed: git checkout origin/stable -- CHANGELOG.md' ) ;
82+ await exec ( ` git checkout origin/${ baseBranch } -- CHANGELOG.md` ) ;
83+ console . log ( ` Executed: git checkout origin/${ baseBranch } -- CHANGELOG.md` ) ;
9584
9685 // Execute mobile-specific commands if REPO is 'mobile'
9786 if ( process . env . REPO === 'mobile' ) {
9887 console . log ( 'Executing mobile-specific commands...' ) ;
9988
100- await exec ( ' git checkout origin/stable -- bitrise.yml' ) ;
101- console . log ( ' Executed: git checkout origin/stable -- bitrise.yml' ) ;
89+ await exec ( ` git checkout origin/${ baseBranch } -- bitrise.yml` ) ;
90+ console . log ( ` Executed: git checkout origin/${ baseBranch } -- bitrise.yml` ) ;
10291
103- await exec ( ' git checkout origin/stable -- android/app/build.gradle' ) ;
104- console . log ( ' Executed: git checkout origin/stable -- android/app/build.gradle' ) ;
92+ await exec ( ` git checkout origin/${ baseBranch } -- android/app/build.gradle` ) ;
93+ console . log ( ` Executed: git checkout origin/${ baseBranch } -- android/app/build.gradle` ) ;
10594
106- await exec ( ' git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj' ) ;
107- console . log ( ' Executed: git checkout origin/stable -- ios/MetaMask.xcodeproj/project.pbxproj' ) ;
95+ await exec ( ` git checkout origin/${ baseBranch } -- ios/MetaMask.xcodeproj/project.pbxproj` ) ;
96+ console . log ( ` Executed: git checkout origin/${ baseBranch } -- ios/MetaMask.xcodeproj/project.pbxproj` ) ;
10897
109- await exec ( ' git checkout origin/stable -- package.json' ) ;
110- console . log ( ' Executed: git checkout origin/stable -- package.json' ) ;
98+ await exec ( ` git checkout origin/${ baseBranch } -- package.json` ) ;
99+ console . log ( ` Executed: git checkout origin/${ baseBranch } -- package.json` ) ;
111100 }
112101 // Execute extension-specific commands if REPO is 'extension'
113102 else if ( process . env . REPO === 'extension' ) {
114103 console . log ( 'Executing extension-specific commands...' ) ;
115104
116105 const { stdout : packageJsonContent } = await exec (
117- ' git show origin/main :package.json' ,
106+ ` git show origin/${ baseBranch } :package.json` ,
118107 ) ;
119108 const packageJson = JSON . parse ( packageJsonContent ) ;
120109 const packageVersion = packageJson . version ;
@@ -175,4 +164,4 @@ async function runGitCommands() {
175164 }
176165}
177166
178- runGitCommands ( ) ;
167+ runGitCommands ( ) ;
0 commit comments