@@ -264,62 +264,18 @@ export const branchSequencer: BranchSequencer = async ({
264264 pathToStackedRebaseDirInsideDotGit,
265265 } ) ;
266266
267- const branchesAndCommits : SimpleBranchAndCommit [ ] = await getBoundariesInclInitial ( {
268- pathToStackedRebaseDirInsideDotGit,
269- pathToStackedRebaseTodoFile,
270- repo,
271- rootLevelCommandName,
272- initialBranch,
273- currentBranch,
274- } ) ;
275-
276- /**
277- * remove the initial branch
278- */
279- branchesAndCommits . shift ( ) ;
280-
281- const originalBoundariesLength : number = branchesAndCommits . length ;
282-
283- const latestBoundary : SimpleBranchAndCommit = branchesAndCommits [ branchesAndCommits . length - 1 ] ;
284-
285- if ( reverseCheckoutOrder ) {
286- branchesAndCommits . reverse ( ) ;
287- }
288-
289- return checkout ( branchesAndCommits ) ;
290-
291- async function checkout ( boundaries : SimpleBranchAndCommit [ ] ) : Promise < void > {
292- if ( ! boundaries . length ) {
293- /**
294- * done.
295- *
296- * now just checkout to the latest branch
297- */
298-
299- await repo . checkoutBranch ( latestBoundary . branchEndFullName ) ;
300-
301- return ;
302- }
303-
304- console . log ( "\ncheckout" , boundaries . length , reverseCheckoutOrder ? "(reversed)" : "" ) ;
305-
306- const goNext = ( ) =>
307- new Promise < void > ( ( r ) => {
308- setTimeout ( ( ) => {
309- checkout ( boundaries . slice ( 1 ) ) . then ( ( ) => r ( ) ) ;
310- } , delayMsBetweenCheckouts ) ;
311- } ) ;
312-
313- const boundary = boundaries [ 0 ] ;
314- const branch = boundary . branchEndFullName ;
315- const targetCommitSHA : string | null = boundary . commitSHA ;
316-
317- if ( ! targetCommitSHA ) {
318- return goNext ( ) ;
319- }
320-
321- let targetBranch = branch . replace ( "refs/heads/" , "" ) ;
322- assert ( targetBranch ) ;
267+ const branchesAndCommits : SimpleBranchAndCommit [ ] = (
268+ await getBoundariesInclInitial ( {
269+ pathToStackedRebaseDirInsideDotGit,
270+ pathToStackedRebaseTodoFile,
271+ repo,
272+ rootLevelCommandName,
273+ initialBranch,
274+ currentBranch,
275+ } )
276+ ) . map ( ( boundary ) => {
277+ boundary . branchEndFullName = boundary . branchEndFullName . replace ( "refs/heads/" , "" ) ;
278+ assert ( boundary . branchEndFullName ) ;
323279
324280 /**
325281 * if we only have the remote branch, but it's not checked out locally,
@@ -330,7 +286,7 @@ export const branchSequencer: BranchSequencer = async ({
330286 // if (!Git.Branch.lookup(repo, targetBranch, Git.Branch.BRANCH.LOCAL)) {
331287 // execSyncInRepo();
332288 // }
333- if ( targetBranch . startsWith ( "refs/remotes/" ) ) {
289+ if ( boundary . branchEndFullName . startsWith ( "refs/remotes/" ) ) {
334290 /**
335291 * TODO - probably should handle this "checkout remote branch locally" logic
336292 * in a better place than here,
@@ -368,10 +324,58 @@ export const branchSequencer: BranchSequencer = async ({
368324 * before doing the checkouts.
369325 *
370326 */
371- targetBranch = targetBranch . replace ( / r e f s \/ r e m o t e s \/ [ ^ / ] + \/ / , "" ) ;
327+ boundary . branchEndFullName = boundary . branchEndFullName . replace ( / r e f s \/ r e m o t e s \/ [ ^ / ] + \/ / , "" ) ;
372328 }
373329
374330 // console.log({ targetCommitSHA, target: targetBranch });
331+ return boundary ;
332+ } ) ;
333+
334+ /**
335+ * remove the initial branch
336+ */
337+ branchesAndCommits . shift ( ) ;
338+
339+ const originalBoundariesLength : number = branchesAndCommits . length ;
340+
341+ const latestBoundary : SimpleBranchAndCommit = branchesAndCommits [ branchesAndCommits . length - 1 ] ;
342+
343+ if ( reverseCheckoutOrder ) {
344+ branchesAndCommits . reverse ( ) ;
345+ }
346+
347+ return checkout ( branchesAndCommits ) ;
348+
349+ async function checkout ( boundaries : SimpleBranchAndCommit [ ] ) : Promise < void > {
350+ if ( ! boundaries . length ) {
351+ /**
352+ * done.
353+ *
354+ * now just checkout to the latest branch
355+ */
356+
357+ // await repo.checkoutBranch(latestBoundary.branchEndFullName);
358+ execSyncInRepo ( `${ gitCmd } checkout ${ latestBoundary . branchEndFullName } ` ) ;
359+
360+ return ;
361+ }
362+
363+ console . log ( "\ncheckout" , boundaries . length , reverseCheckoutOrder ? "(reversed)" : "" ) ;
364+
365+ const goNext = ( ) =>
366+ new Promise < void > ( ( r ) => {
367+ setTimeout ( ( ) => {
368+ checkout ( boundaries . slice ( 1 ) ) . then ( ( ) => r ( ) ) ;
369+ } , delayMsBetweenCheckouts ) ;
370+ } ) ;
371+
372+ const boundary = boundaries [ 0 ] ;
373+ const targetBranch = boundary . branchEndFullName ;
374+ const targetCommitSHA : string | null = boundary . commitSHA ;
375+
376+ if ( ! targetCommitSHA ) {
377+ return goNext ( ) ;
378+ }
375379
376380 const isLatestBranch : boolean = reverseCheckoutOrder
377381 ? boundaries . length === originalBoundariesLength
0 commit comments