55 "bytes"
66 "context"
77 "crypto/sha256"
8+ b64 "encoding/base64"
89 "encoding/csv"
910 "encoding/json"
1011 "flag"
@@ -2452,6 +2453,7 @@ func (j *DSGit) Sync(ctx *shared.Ctx) (err error) {
24522453 Hash : record [4 ],
24532454 Orphaned : orphaned ,
24542455 FromDL : fromDL ,
2456+ Content : record [7 ],
24552457 }
24562458 }
24572459 if ctx .DateTo != nil {
@@ -2821,10 +2823,10 @@ func (j *DSGit) createCacheFile(cache []CommitCache, path string) error {
28212823 cachedCommits [comm .EntityID ] = comm
28222824 }
28232825 records := [][]string {
2824- {"timestamp" , "entity_id" , "source_entity_id" , "file_location" , "hash" , "orphaned" , "from_dl" },
2826+ {"timestamp" , "entity_id" , "source_entity_id" , "file_location" , "hash" , "orphaned" , "from_dl" , "content" },
28252827 }
28262828 for _ , c := range cachedCommits {
2827- records = append (records , []string {c .Timestamp , c .EntityID , c .SourceEntityID , c .FileLocation , c .Hash , strconv .FormatBool (c .Orphaned ), strconv .FormatBool (c .FromDL )})
2829+ records = append (records , []string {c .Timestamp , c .EntityID , c .SourceEntityID , c .FileLocation , c .Hash , strconv .FormatBool (c .Orphaned ), strconv .FormatBool (c .FromDL ), c . Content })
28282830 }
28292831
28302832 csvFile , err := os .Create (commitsCacheFile )
@@ -2885,14 +2887,24 @@ func (j *DSGit) handleDataLakeOrphans() {
28852887 Source : insights .Source (j .RepositorySource ),
28862888 }
28872889
2888- for orphanedID , v := range cachedCommits {
2890+ for _ , v := range cachedCommits {
28892891 if v .Orphaned && v .FromDL {
2890- commit := git.CommitUpdatedEvent {
2892+ commitB , err := b64 .StdEncoding .DecodeString (v .Content )
2893+ if err != nil {
2894+ j .log .WithFields (logrus.Fields {"operation" : "handleDataLakeOrphans" }).Errorf ("error decode datalake orphand commit: %+v" , err )
2895+ }
2896+ var commit git.Commit
2897+ err = jsoniter .Unmarshal (commitB , & commit )
2898+ if err != nil {
2899+ j .log .WithFields (logrus.Fields {"operation" : "handleDataLakeOrphans" }).Errorf ("error unmarshall datalake orphand commit: %+v" , err )
2900+ continue
2901+ }
2902+ commitEvent := git.CommitUpdatedEvent {
28912903 CommitBaseEvent : commitBaseEvent ,
28922904 BaseEvent : baseEvent ,
2893- Payload : git. Commit { ID : orphanedID , Orphaned : true } ,
2905+ Payload : commit ,
28942906 }
2895- formattedData = append (formattedData , commit )
2907+ formattedData = append (formattedData , commitEvent )
28962908 }
28972909 }
28982910
@@ -2907,6 +2919,7 @@ func (j *DSGit) handleDataLakeOrphans() {
29072919 commit := cachedCommits [id ]
29082920 commit .FromDL = false
29092921 commit .FileLocation = path
2922+ commit .Content = ""
29102923 cachedCommits [id ] = commit
29112924 }
29122925 if err = j .createCacheFile ([]CommitCache {}, "" ); err != nil {
@@ -2927,6 +2940,7 @@ type CommitCache struct {
29272940 Hash string `json:"hash"`
29282941 Orphaned bool `json:"orphaned"`
29292942 FromDL bool `json:"from_dl"`
2943+ Content string `json:"content"`
29302944}
29312945
29322946// ReportData schema
0 commit comments