@@ -399,8 +399,13 @@ export class GitManager {
399399 await writable . close ( ) ;
400400 console . log ( ' ✓ Synced:' , fileName ) ;
401401 }
402- } catch ( e ) {
403- console . error ( ' Error syncing file:' , relativePath , e ) ;
402+ } catch ( e : any ) {
403+ if ( e . name === 'NoModificationAllowedError' ) {
404+ // This is expected for some git objects/pack files that are read-only
405+ console . warn ( ` Read-only file detected (skipping): ${ relativePath } ` ) ;
406+ } else {
407+ console . error ( ' Error syncing file:' , relativePath , e ) ;
408+ }
404409 }
405410 }
406411
@@ -495,6 +500,7 @@ export class GitManager {
495500 name : 'EasyEdit User' ,
496501497502 } ,
503+ corsProxy : 'https://cors.isomorphic-git.org' , // Add CORS proxy
498504 } ;
499505
500506 if ( this . credentials ) {
@@ -553,7 +559,31 @@ export class GitManager {
553559 }
554560
555561 console . log ( 'Calling git.push()...' ) ;
556- await git . push ( pushOptions ) ;
562+ const pushResult = await git . push ( pushOptions ) ;
563+ console . log ( 'Push result:' , pushResult ) ;
564+
565+ if ( pushResult . ok === false ) {
566+ throw new Error ( `Push failed: ${ pushResult . error || 'Unknown error' } ` ) ;
567+ }
568+
569+ // Check individual refs for errors
570+ if ( pushResult . refs ) {
571+ for ( const [ ref , result ] of Object . entries ( pushResult . refs ) ) {
572+ if ( ! result . ok ) {
573+ throw new Error ( `Failed to push ref ${ ref } : ${ result . error } ` ) ;
574+ }
575+ }
576+ }
577+
578+ // Sync the .git directory back to disk to update local status
579+ if ( this . dirHandle ) {
580+ console . log ( 'Syncing .git directory back to disk...' ) ;
581+ const gitPath = `${ this . repoDir } /.git` ;
582+ // Sync .git content (repoName='.git' forces strict sync into .git folder)
583+ await this . syncToFileSystem ( gitPath , this . dirHandle , '.git' ) ;
584+ console . log ( '.git directory synced back to disk' ) ;
585+ }
586+
557587 console . log ( '=== Git Push Completed Successfully ===' ) ;
558588 } catch ( error : any ) {
559589 console . error ( '=== Git Push Failed ===' ) ;
@@ -591,6 +621,7 @@ export class GitManager {
591621 http,
592622 dir : this . repoDir ,
593623 remote : 'origin' ,
624+ corsProxy : 'https://cors.isomorphic-git.org' , // Add CORS proxy
594625 } ;
595626
596627 if ( this . credentials ) {
@@ -600,6 +631,7 @@ export class GitManager {
600631 } ) ;
601632 }
602633
634+ // Fetch does not return a result with ok/error, it throws on failure
603635 await git . fetch ( fetchOptions ) ;
604636 } catch ( error ) {
605637 throw new Error ( `Failed to fetch from remote: ${ ( error as Error ) . message } ` ) ;
@@ -704,11 +736,17 @@ export class GitManager {
704736 } ) ;
705737
706738 if ( status === 'modified' ) {
739+ result . staged . push ( filepath ) ;
740+ } else if ( status === '*modified' ) {
707741 result . modified . push ( filepath ) ;
708742 } else if ( status === 'added' ) {
709743 result . staged . push ( filepath ) ;
710744 } else if ( status === '*added' ) {
711745 result . untracked . push ( filepath ) ;
746+ } else if ( status === 'deleted' ) {
747+ result . staged . push ( filepath ) ;
748+ } else if ( status === '*deleted' ) {
749+ result . modified . push ( filepath ) ;
712750 }
713751 }
714752
0 commit comments