@@ -170,13 +170,28 @@ const makeFileChanges = async (
170170 changegroup === "with-unchanged-symlink" ||
171171 changegroup === "with-changed-symlink"
172172 ) {
173+ console . log ( "[DEBUG makeFileChanges] Creating some-dir directory" ) ;
173174 await fs . promises . mkdir ( path . join ( repoDirectory , "some-dir" ) , {
174175 recursive : true ,
175176 } ) ;
177+ console . log (
178+ "[DEBUG makeFileChanges] Creating symlink ../README.md -> some-dir/nested" ,
179+ ) ;
176180 await fs . promises . symlink (
177181 "../README.md" ,
178182 path . join ( repoDirectory , "some-dir" , "nested" ) ,
179183 ) ;
184+
185+ // Verify symlink was created
186+ const createdTarget = await fs . promises . readlink (
187+ path . join ( repoDirectory , "some-dir" , "nested" ) ,
188+ ) ;
189+ console . log (
190+ "[DEBUG makeFileChanges] Symlink created, target:" ,
191+ createdTarget ,
192+ ) ;
193+
194+ console . log ( "[DEBUG makeFileChanges] Setting git config user.email" ) ;
180195 await new Promise < void > ( ( resolve ) => {
181196 execFile (
182197 "git" ,
@@ -185,6 +200,7 @@ const makeFileChanges = async (
185200 ( ) => resolve ( ) ,
186201 ) ;
187202 } ) ;
203+ console . log ( "[DEBUG makeFileChanges] Setting git config user.name" ) ;
188204 await new Promise < void > ( ( resolve ) => {
189205 execFile (
190206 "git" ,
@@ -193,19 +209,61 @@ const makeFileChanges = async (
193209 ( ) => resolve ( ) ,
194210 ) ;
195211 } ) ;
212+ console . log ( "[DEBUG makeFileChanges] git.add some-dir/nested" ) ;
196213 await git . add ( {
197214 fs,
198215 dir : repoDirectory ,
199216 filepath : "some-dir/nested" ,
200217 } ) ;
201- await git . commit ( {
218+ const headBeforeCommit = await git . resolveRef ( { fs, dir : repoDirectory , ref : "HEAD" } ) ;
219+ console . log ( "[DEBUG makeFileChanges] HEAD before commit:" , headBeforeCommit ) ;
220+ console . log ( "[DEBUG makeFileChanges] git.commit 'Add symlink'" ) ;
221+ const commitResult = await git . commit ( {
202222 fs,
203223 dir : repoDirectory ,
204224 message : "Add symlink" ,
205225 author : { name : "Test" , email : "test@test.com" } ,
206226 } ) ;
227+ console . log ( "[DEBUG makeFileChanges] Commit created:" , commitResult ) ;
228+
229+ // Verify HEAD was updated
230+ const headAfterCommit = await git . resolveRef ( { fs, dir : repoDirectory , ref : "HEAD" } ) ;
231+ console . log ( "[DEBUG makeFileChanges] HEAD after commit:" , headAfterCommit ) ;
232+ console . log ( "[DEBUG makeFileChanges] HEAD matches commit?" , headAfterCommit === commitResult ) ;
233+
234+ // Verify the symlink is in the commit
235+ const commitObj = await git . readCommit ( {
236+ fs,
237+ dir : repoDirectory ,
238+ oid : commitResult ,
239+ } ) ;
240+ const tree = await git . readTree ( {
241+ fs,
242+ dir : repoDirectory ,
243+ oid : commitObj . commit . tree ,
244+ } ) ;
245+ const someDirEntry = tree . tree . find ( ( e ) => e . path === "some-dir" ) ;
246+ console . log (
247+ "[DEBUG makeFileChanges] some-dir entry after commit:" ,
248+ JSON . stringify ( someDirEntry ) ,
249+ ) ;
250+ if ( someDirEntry ) {
251+ const someDirTree = await git . readTree ( {
252+ fs,
253+ dir : repoDirectory ,
254+ oid : someDirEntry . oid ,
255+ } ) ;
256+ const nestedEntry = someDirTree . tree . find ( ( e ) => e . path === "nested" ) ;
257+ console . log (
258+ "[DEBUG makeFileChanges] some-dir/nested entry after commit:" ,
259+ JSON . stringify ( nestedEntry ) ,
260+ ) ;
261+ }
207262
208263 if ( changegroup === "with-changed-symlink" ) {
264+ console . log (
265+ "[DEBUG makeFileChanges] Changing symlink target to ../LICENSE" ,
266+ ) ;
209267 await fs . promises . rm ( path . join ( repoDirectory , "some-dir" , "nested" ) ) ;
210268 await fs . promises . symlink (
211269 "../LICENSE" ,
@@ -373,13 +431,16 @@ describe("git", () => {
373431 } ) ;
374432 }
375433
376- it ( `should allow unchanged symlinks without throwing` , async ( ) => {
434+ it . only ( `should allow unchanged symlinks without throwing` , async ( ) => {
377435 const branch = `${ TEST_BRANCH_PREFIX } -unchanged-symlink` ;
378436 branches . push ( branch ) ;
379437
438+ console . log ( "[DEBUG] Step 1: Creating test directory" ) ;
380439 await fs . promises . mkdir ( testDir , { recursive : true } ) ;
381440 const repoDirectory = path . join ( testDir , `repo-unchanged-symlink` ) ;
441+ console . log ( "[DEBUG] repoDirectory:" , repoDirectory ) ;
382442
443+ console . log ( "[DEBUG] Step 2: Cloning repo" ) ;
383444 await new Promise < void > ( ( resolve , reject ) => {
384445 const p = execFile (
385446 "git" ,
@@ -396,13 +457,90 @@ describe("git", () => {
396457 p . stdout ?. pipe ( process . stdout ) ;
397458 p . stderr ?. pipe ( process . stderr ) ;
398459 } ) ;
460+ console . log ( "[DEBUG] Step 2 done: Clone completed" ) ;
399461
462+ console . log ( "[DEBUG] Step 3: Calling makeFileChanges" ) ;
400463 await makeFileChanges ( repoDirectory , "with-unchanged-symlink" ) ;
464+ console . log ( "[DEBUG] Step 3 done: makeFileChanges completed" ) ;
465+
466+ // Log symlink info
467+ const symlinkPath = path . join ( repoDirectory , "some-dir" , "nested" ) ;
468+ console . log ( "[DEBUG] Step 4: Checking symlink state" ) ;
469+ try {
470+ const symlinkTarget = await fs . promises . readlink ( symlinkPath ) ;
471+ console . log ( "[DEBUG] Symlink target:" , symlinkTarget ) ;
472+ const symlinkStat = await fs . promises . lstat ( symlinkPath ) ;
473+ console . log (
474+ "[DEBUG] Symlink lstat mode:" ,
475+ symlinkStat . mode . toString ( 8 ) ,
476+ ) ;
477+ } catch ( e ) {
478+ console . log ( "[DEBUG] Error reading symlink:" , e ) ;
479+ }
480+
481+ // Log git status
482+ console . log ( "[DEBUG] Step 5: Git status in cloned repo" ) ;
483+ const gitStatus = await git . statusMatrix ( { fs, dir : repoDirectory } ) ;
484+ const changedFiles = gitStatus . filter (
485+ ( [ , head , workdir , stage ] ) =>
486+ head !== workdir || head !== stage || workdir !== stage ,
487+ ) ;
488+ console . log ( "[DEBUG] Changed files count:" , changedFiles . length ) ;
489+ console . log (
490+ "[DEBUG] Changed files:" ,
491+ JSON . stringify ( changedFiles . slice ( 0 , 20 ) ) ,
492+ ) ;
493+
494+ // Log HEAD commit and symlink oid
495+ console . log ( "[DEBUG] Step 6: Getting HEAD commit info" ) ;
496+ const headCommit = await git . resolveRef ( {
497+ fs,
498+ dir : repoDirectory ,
499+ ref : "HEAD" ,
500+ } ) ;
501+ console . log ( "[DEBUG] HEAD commit:" , headCommit ) ;
502+
503+ try {
504+ const commitObj = await git . readCommit ( {
505+ fs,
506+ dir : repoDirectory ,
507+ oid : headCommit ,
508+ } ) ;
509+ console . log ( "[DEBUG] HEAD tree:" , commitObj . commit . tree ) ;
510+
511+ // Try to get the symlink entry from the tree
512+ const tree = await git . readTree ( {
513+ fs,
514+ dir : repoDirectory ,
515+ oid : commitObj . commit . tree ,
516+ } ) ;
517+ const someDirEntry = tree . tree . find ( ( e ) => e . path === "some-dir" ) ;
518+ console . log (
519+ "[DEBUG] some-dir entry in tree:" ,
520+ JSON . stringify ( someDirEntry ) ,
521+ ) ;
522+
523+ if ( someDirEntry ) {
524+ const someDirTree = await git . readTree ( {
525+ fs,
526+ dir : repoDirectory ,
527+ oid : someDirEntry . oid ,
528+ } ) ;
529+ const nestedEntry = someDirTree . tree . find ( ( e ) => e . path === "nested" ) ;
530+ console . log (
531+ "[DEBUG] some-dir/nested entry in tree:" ,
532+ JSON . stringify ( nestedEntry ) ,
533+ ) ;
534+ }
535+ } catch ( e ) {
536+ console . log ( "[DEBUG] Error reading commit/tree:" , e ) ;
537+ }
401538
402539 // The symlink was committed locally and is unchanged in workdir.
403540 // The tree walk should skip it since oids match.
404541 // GitHub push may fail because local commit doesn't exist on GitHub,
405542 // but the key is that no symlink error is thrown.
543+ console . log ( "[DEBUG] Step 7: Calling commitChangesFromRepo" ) ;
406544 try {
407545 await commitChangesFromRepo ( {
408546 octokit,
@@ -416,9 +554,12 @@ describe("git", () => {
416554 log,
417555 } ) ;
418556
557+ console . log ( "[DEBUG] Step 7 done: commitChangesFromRepo succeeded" ) ;
419558 await waitForGitHubToBeReady ( ) ;
420559 await makeFileChangeAssertions ( branch ) ;
421560 } catch ( error ) {
561+ console . log ( "[DEBUG] Step 7 error:" , ( error as Error ) . message ) ;
562+ console . log ( "[DEBUG] Full error:" , error ) ;
422563 expect ( ( error as Error ) . message ) . not . toContain ( "Unexpected symlink" ) ;
423564 expect ( ( error as Error ) . message ) . not . toContain ( "Unexpected executable" ) ;
424565 }
0 commit comments