@@ -162,6 +162,21 @@ function removeFolder( relativePath ) {
162
162
fs . rmSync ( `${ __dirname } /${ relativePath } ` , { recursive : true , force : true } ) ;
163
163
}
164
164
165
+ async function updateCodexRepoBranchIfNecessary ( opts , mwBranch ) {
166
+ // If the user hasn't specified a '--repo-branch' for codex
167
+ // determine which version the MW branch wants and use it
168
+ if ( ! opts . repoBranch ?. some ( ( branch ) => branch . startsWith ( 'design/codex:' ) ) ) {
169
+ let codexVersion ;
170
+ try {
171
+ codexVersion = await getCodexVersionForMWBranch ( mwBranch ) ;
172
+ } catch ( error ) {
173
+ codexVersion = await getLatestCodexVersion ( ) ;
174
+ console . log ( `\x1b[33m${ error . message } Falling back to latest Codex version ${ codexVersion } \x1b[0m` ) ;
175
+ }
176
+ opts . repoBranch = [ ...( opts . repoBranch ?? [ ] ) , `design/codex:${ codexVersion } ` ] ;
177
+ }
178
+ }
179
+
165
180
/**
166
181
* @typedef {Object } CommandOptions
167
182
* @property {string[] } [changeId]
@@ -183,26 +198,12 @@ async function processCommand( type, opts, runSilently = false ) {
183
198
184
199
setEnvironmentFlagIfGroup ( 'ENABLE_WIKILAMBDA' , 'wikilambda' , group ) ;
185
200
186
- const activeBranch = await getActiveBranch ( opts ) ;
187
-
188
- // If the user hasn't specified a '--repo-branch' for codex
189
- // determine which version the MW branch wants and use it
190
- if ( ! opts . repoBranch ?. some ( ( branch ) => branch . startsWith ( 'design/codex:' ) ) ) {
191
- let codexVersion ;
192
- try {
193
- codexVersion = await getCodexVersionForMWBranch ( activeBranch ) ;
194
- } catch ( error ) {
195
- codexVersion = await getLatestCodexVersion ( ) ;
196
- console . log ( `\x1b[33m${ error . message } Falling back to latest Codex version ${ codexVersion } \x1b[0m` ) ;
197
- }
198
- opts . repoBranch = [ ...( opts . repoBranch ?? [ ] ) , `design/codex:${ codexVersion } ` ] ;
199
- }
200
- console . log ( 'repoBranch:' ) ;
201
- console . log ( opts . repoBranch ) ;
202
- // process.exit ( 1 )
201
+ const activeMWBranch = await getActiveBranch ( opts ) ;
202
+
203
+ await updateCodexRepoBranchIfNecessary ( opts , activeMWBranch ) ;
203
204
204
205
const description = getDescription ( opts ) ;
205
- updateContext ( group , type , activeBranch , description ) ;
206
+ updateContext ( group , type , activeMWBranch , description ) ;
206
207
207
208
await prepareDockerEnvironment ( opts ) ;
208
209
const { stdout : stdout1 } = await simpleSpawn . exec ( './purgeParserCache.sh' ) ;
0 commit comments