From 1e4b0c0d3742bc953d5b21e3d901e94d1268c72f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 13 Dec 2024 17:31:40 -0600 Subject: [PATCH] check for notes before deleting them --- autogen.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autogen.go b/autogen.go index c216716..8d78780 100644 --- a/autogen.go +++ b/autogen.go @@ -13,9 +13,14 @@ import ( // del : true means empty out existing notes, otherwise append func (repo *Repo) AutogenSave(files []string, refname string, del bool) error { if del { - cmd := []string{"git", "notes", "remove", refname} + cmd := []string{"git", "notes", "show", refname} if err := repo.StrictRun(cmd); err != nil { - return err + // if there are not any notes, no need to remove them + } else { + cmd := []string{"git", "notes", "remove", refname} + if err := repo.StrictRun(cmd); err != nil { + return err + } } } for _, fname := range files {