From 049656fed3908067ccfbc2b8ad625f85b9edae3c Mon Sep 17 00:00:00 2001 From: sumi Date: Mon, 15 Dec 2025 01:31:31 -0600 Subject: [PATCH] automated snapshot --- storage.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage.go b/storage.go index b1fc9bf..f16b00d 100644 --- a/storage.go +++ b/storage.go @@ -94,7 +94,7 @@ func (s *Storage) Save(img *rl.Image) (string, error) { rl.ExportImage(*img, snapshotPng) - hash, branch, committed, err := CommitAllIfDirty(s.repoRoot, "automated snapshot") + hash, branch, committed, err := CommitAllIfDirty(s.repoRoot, "automated snapshot", s.log) if err != nil { s.log.Printf("Error getting working tree in a known clean state: %v", err) @@ -157,15 +157,17 @@ func IsDirty(repoPath string) (bool, error) { return !status.IsClean(), nil } -func CommitAllIfDirty(repoPath, message string) (commitHash string, branch string, committed bool, err error) { +func CommitAllIfDirty(repoPath, message string, log *log.Logger) (commitHash string, branch string, committed bool, err error) { r, err := git.PlainOpen(repoPath) if err != nil { + log.Printf("Error opening git repo") return } // Determine branch (may be empty if detached) ref, err := r.Head() if err != nil { + log.Printf("Error determining head commit") return } if ref.Name().IsBranch() { @@ -174,11 +176,13 @@ func CommitAllIfDirty(repoPath, message string) (commitHash string, branch strin wt, err := r.Worktree() if err != nil { + log.Printf("Error getting worktree state") return } status, err := wt.Status() if err != nil { + log.Printf("Error getting worktree status") return } @@ -188,6 +192,7 @@ func CommitAllIfDirty(repoPath, message string) (commitHash string, branch strin // Stage everything (git add -A) if err = wt.AddWithOptions(&git.AddOptions{All: true}); err != nil { + log.Printf("Error adding git changes to index") return } @@ -199,6 +204,7 @@ func CommitAllIfDirty(repoPath, message string) (commitHash string, branch strin }, }) if err != nil { + log.Printf("Error creating commit") return }