1- import { execSync } from 'child_process' ;
1+ import { spawnSync } from 'child_process' ;
22import * as core from '@actions/core' ;
33import { Benchmark } from './extract' ;
44
@@ -7,7 +7,7 @@ export class GitGraphAnalyzer {
77
88 constructor ( ) {
99 try {
10- execSync ( 'git --version' , { stdio : 'ignore' } ) ;
10+ spawnSync ( 'git' , [ ' --version'] , { stdio : 'ignore' } ) ;
1111 this . gitCliAvailable = true ;
1212 } catch ( e ) {
1313 this . gitCliAvailable = false ;
@@ -31,12 +31,16 @@ export class GitGraphAnalyzer {
3131 }
3232
3333 try {
34- const output = execSync ( ` git log --oneline --topo-order ${ ref } ` , {
34+ const result = spawnSync ( ' git' , [ ' log' , ' --oneline' , ' --topo-order' , ref ] , {
3535 encoding : 'utf8' ,
3636 cwd : process . env . GITHUB_WORKSPACE ?? process . cwd ( ) ,
3737 } ) ;
3838
39- return output
39+ if ( result . error ) {
40+ throw result . error ;
41+ }
42+
43+ return result . stdout
4044 . split ( '\n' )
4145 . filter ( ( line ) => line . trim ( ) )
4246 . map ( ( line ) => line . split ( ' ' ) [ 0 ] ) ; // Extract SHA from "sha message"
@@ -97,7 +101,9 @@ export class GitGraphAnalyzer {
97101 }
98102
99103 // Create a set of ancestor SHAs for quick lookup (excluding the commit itself)
100- const ancestorSet = new Set ( ancestry . slice ( 1 ) ) ; // Skip first element (the commit itself)
104+ // Skip first element only if it matches the commit (it should)
105+ const startIndex = ancestry [ 0 ] === newCommitSha ? 1 : 0 ;
106+ const ancestorSet = new Set ( ancestry . slice ( startIndex ) ) ;
101107
102108 // Find the most recent ancestor in the existing suites
103109 // Iterate through suites from end to beginning to find the most recent one
0 commit comments