Skip to content

Commit

Permalink
wip: started parsing diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
graza-io committed Nov 13, 2024
1 parent 738c115 commit e069715
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions internal/snapshot/snapshot_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,32 @@ func updateDiffSnap(changeLog diff.Changelog, diffSnap *map[string]interface{})
var err error
topLevel := change.Path[0]
switch topLevel {
case "layout", "panels":
case "layout":
switch change.Type {
case "create":
err = addKeyValueAtPath(*diffSnap, change.Path, "__diff", "inserted")
if topLevel == "panels" {
// PANEL SPECIFIC LOGIC
fmt.Println("a")
}
case "delete":
err = addKeyValueAtPath(*diffSnap, change.Path, "__diff", "deleted")
if topLevel == "panels" {
// PANEL SPECIFIC LOGIC
fmt.Println("a")
}
// TODO: #snapshot we need to extract the deleted layout item and inject into the diff
case "update":
err = addKeyValueAtPath(*diffSnap, change.Path, "__diff", "updated")
if topLevel == "panels" {
// PANEL SPECIFIC LOGIC
fmt.Println("a")
}
default:
continue
}
if err != nil {
return fmt.Errorf("failed to update diff snapshot: %w", err)
}
case "panels":
switch change.Type {

Check failure on line 138 in internal/snapshot/snapshot_diff.go

View workflow job for this annotation

GitHub Actions / Test Linting

use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
case "create":
err = addKeyValueAtPath(*diffSnap, change.Path, "__diff", "inserted")
case "delete":
fmt.Println("delete")
case "update":
updatePath := change.Path[:len(change.Path)-1]
updateKey := fmt.Sprintf("%s_diff", change.Path[len(change.Path)-1])
err = addKeyValueAtPath(*diffSnap, updatePath, "__diff", "updated")
err = addKeyValueAtPath(*diffSnap, updatePath, updateKey, change.From)
default:
continue
}
Expand Down

0 comments on commit e069715

Please sign in to comment.