check for notes before deleting them

This commit is contained in:
Jeff Carr 2024-12-13 17:31:40 -06:00
parent 2574ec733a
commit 1e4b0c0d37
1 changed files with 7 additions and 2 deletions

View File

@ -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 {