@@ -261,9 +261,10 @@ class CoveragePipe { // or Changes for the future???
261261 */
262262 #getChangedFilesFromGit( cmd ) {
263263 try {
264+ // Capture stderr (instead of ignoring it) so Git's actual error is available for diagnostics
264265 const result = execSync ( cmd , {
265266 encoding : 'utf-8' ,
266- stdio : [ 'pipe' , 'pipe' , 'ignore ' ]
267+ stdio : [ 'pipe' , 'pipe' , 'pipe ' ]
267268 } ) ;
268269
269270 return result
@@ -272,16 +273,33 @@ class CoveragePipe { // or Changes for the future???
272273 . filter ( Boolean ) ;
273274 }
274275 catch ( err ) {
275- const errorMessage = err . message || '' ;
276- // Git edge: Not a git repository or other error
276+ // Prefer Git's own stderr output, fall back to the generic error message
277+ const gitOutput = ( err . stderr || '' ) . toString ( ) . trim ( ) ;
278+ const errorMessage = gitOutput || err . message || '' ;
279+
280+ // Git edge: Not a git repository
277281 if ( errorMessage . includes ( 'Not a git repository' ) ) {
278- log . error ( '❌ Error: This folder is not a Git repository.' ) ;
282+ log . error ( '❌ Error: This folder is not a Git repository.' ) ;
283+ return [ ] ;
279284 }
280- else {
281- throw new Error ( `❌ Git command failed ("${ cmd } "):\n` , errorMessage ) ;
285+
286+ // Git edge: the branch/ref to diff against is not available locally.
287+ // This is common in CI, where a shallow checkout fetches only the current branch.
288+ if (
289+ errorMessage . includes ( 'unknown revision' ) ||
290+ errorMessage . includes ( 'ambiguous argument' ) ||
291+ errorMessage . includes ( 'bad revision' )
292+ ) {
293+ log . error ( `❌ Git command failed ("${ cmd } "):\n${ errorMessage } ` ) ;
294+ log . error (
295+ `🔍 Branch "${ this . branch } " was not found locally. ` +
296+ `In CI this usually means a shallow checkout — fetch full history first, e.g. ` +
297+ `actions/checkout with "fetch-depth: 0", or run "git fetch origin ${ this . branch } :${ this . branch } ".`
298+ ) ;
299+ return [ ] ;
282300 }
283301
284- return [ ] ;
302+ throw new Error ( `❌ Git command failed (" ${ cmd } "):\n ${ errorMessage } ` ) ;
285303 }
286304 }
287305
0 commit comments