From ac61c2470d5ce63e879a9fb18ddecbb9b54b077a Mon Sep 17 00:00:00 2001 From: Denis Gribanov Date: Mon, 23 Feb 2026 21:00:10 +0300 Subject: [PATCH] [AIR-3045] qs: add notes as single git operation instead of 3 --- gitcmds/notes.go | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/gitcmds/notes.go b/gitcmds/notes.go index 4bd7329..8ba3ca5 100644 --- a/gitcmds/notes.go +++ b/gitcmds/notes.go @@ -15,30 +15,27 @@ import ( ) func AddNotes(wd string, notes []string) error { - if len(notes) == 0 { + var filtered []string + for _, s := range notes { + if str := strings.TrimSpace(s); len(str) > 0 { + filtered = append(filtered, str) + } + } + if len(filtered) == 0 { return nil } - // Add new Notes - for _, s := range notes { - str := strings.TrimSpace(s) - if len(str) > 0 { - stdout, stderr, err := new(exec.PipedExec). - Command(git, "notes", "append", "-m", str). - WorkingDir(wd). - RunToStrings() - if err != nil { - logger.Verbose(stderr) - - if len(stderr) > 0 { - return errors.New(stderr) - } - - return fmt.Errorf("failed to add note: %w", err) - } - printLn(stdout) + stdout, stderr, err := new(exec.PipedExec). + Command(git, "notes", "append", "-m", strings.Join(filtered, caret+caret)). // double caret for backward compatibility + WorkingDir(wd). + RunToStrings() + if err != nil { + logger.Verbose(stderr) + if len(stderr) > 0 { + return errors.New(stderr) } + return fmt.Errorf("failed to add note: %w", err) } - + printLn(stdout) return nil }