@@ -14,6 +14,7 @@ import {
1414 extractNumberFromFilename
1515} from "./util/templateUtils" ;
1616import { getEffectiveRepoSettings } from "./util/settingsUtils" ;
17+ import { extractPersistBlocks , mergePersistBlocks , shouldUpdateContent } from "./util/persistUtils" ;
1718
1819export class FileManager {
1920 constructor (
@@ -430,12 +431,35 @@ export class FileManager {
430431 const updateMode = repo . issueUpdateMode ;
431432
432433 if ( updateMode === "update" ) {
434+ // Read existing content first
435+ const existingContent = await this . app . vault . read ( file ) ;
436+
437+ // Check if content needs updating based on updated_at field
438+ if ( ! shouldUpdateContent ( existingContent , issue . updated_at ) ) {
439+ this . noticeManager . debug (
440+ `Skipped update for issue ${ issue . number } : no changes detected (updated_at match)`
441+ ) ;
442+ return ;
443+ }
444+
445+ // Extract persist blocks from existing content
446+ const persistBlocks = extractPersistBlocks ( existingContent ) ;
447+
433448 // Create the complete new content with updated frontmatter
434- const updatedContent = await this . createIssueContent (
449+ let updatedContent = await this . createIssueContent (
435450 issue ,
436451 repo ,
437452 comments ,
438453 ) ;
454+
455+ // Merge persist blocks back into new content
456+ if ( persistBlocks . size > 0 ) {
457+ updatedContent = mergePersistBlocks ( updatedContent , existingContent , persistBlocks ) ;
458+ this . noticeManager . debug (
459+ `Restored ${ persistBlocks . size } persist block(s) for issue ${ issue . number } `
460+ ) ;
461+ }
462+
439463 await this . app . vault . modify ( file , updatedContent ) ;
440464 this . noticeManager . debug ( `Updated issue ${ issue . number } ` ) ;
441465 } else if ( updateMode === "append" ) {
@@ -527,12 +551,35 @@ export class FileManager {
527551 const updateMode = repo . pullRequestUpdateMode ;
528552
529553 if ( updateMode === "update" ) {
554+ // Read existing content first
555+ const existingContent = await this . app . vault . read ( file ) ;
556+
557+ // Check if content needs updating based on updated_at field
558+ if ( ! shouldUpdateContent ( existingContent , pr . updated_at ) ) {
559+ this . noticeManager . debug (
560+ `Skipped update for PR ${ pr . number } : no changes detected (updated_at match)`
561+ ) ;
562+ return ;
563+ }
564+
565+ // Extract persist blocks from existing content
566+ const persistBlocks = extractPersistBlocks ( existingContent ) ;
567+
530568 // Create the complete new content with updated frontmatter
531- const updatedContent = await this . createPullRequestContent (
569+ let updatedContent = await this . createPullRequestContent (
532570 pr ,
533571 repo ,
534572 comments ,
535573 ) ;
574+
575+ // Merge persist blocks back into new content
576+ if ( persistBlocks . size > 0 ) {
577+ updatedContent = mergePersistBlocks ( updatedContent , existingContent , persistBlocks ) ;
578+ this . noticeManager . debug (
579+ `Restored ${ persistBlocks . size } persist block(s) for PR ${ pr . number } `
580+ ) ;
581+ }
582+
536583 await this . app . vault . modify ( file , updatedContent ) ;
537584 this . noticeManager . debug ( `Updated PR ${ pr . number } ` ) ;
538585 } else if ( updateMode === "append" ) {
@@ -619,6 +666,11 @@ created: "${
619666 ? format ( new Date ( issue . created_at ) , this . settings . dateFormat )
620667 : new Date ( issue . created_at ) . toLocaleString ( )
621668 } "
669+ updated: "${
670+ this . settings . dateFormat !== ""
671+ ? format ( new Date ( issue . updated_at ) , this . settings . dateFormat )
672+ : new Date ( issue . updated_at ) . toLocaleString ( )
673+ } "
622674url: "${ issue . html_url } "
623675opened_by: "${ issue . user ?. login } "
624676assignees: [${ (
@@ -675,6 +727,11 @@ created: "${
675727 ? format ( new Date ( pr . created_at ) , this . settings . dateFormat )
676728 : new Date ( pr . created_at ) . toLocaleString ( )
677729 } "
730+ updated: "${
731+ this . settings . dateFormat !== ""
732+ ? format ( new Date ( pr . updated_at ) , this . settings . dateFormat )
733+ : new Date ( pr . updated_at ) . toLocaleString ( )
734+ } "
678735url: "${ pr . html_url } "
679736opened_by: "${ pr . user ?. login } "
680737assignees: [${ (
0 commit comments