From da9c133f1fa06a83c83fd15e5a381e67ac77241f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 16:22:37 +0000 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20fmt.Errorf(static)=20=E2=86=92=20e?= =?UTF-8?q?rrors.New?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- agentci/config.go | 3 ++- jobrunner/journal.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/agentci/config.go b/agentci/config.go index f2297c8..1fa8eb5 100644 --- a/agentci/config.go +++ b/agentci/config.go @@ -2,6 +2,7 @@ package agentci import ( + "errors" "fmt" "forge.lthn.ai/core/go/pkg/config" @@ -125,7 +126,7 @@ func SaveAgent(cfg *config.Config, name string, ac AgentConfig) error { func RemoveAgent(cfg *config.Config, name string) error { var agents map[string]AgentConfig if err := cfg.Get("agentci.agents", &agents); err != nil { - return fmt.Errorf("no agents configured") + return errors.New("no agents configured") } if _, ok := agents[name]; !ok { return fmt.Errorf("agent %q not found", name) diff --git a/jobrunner/journal.go b/jobrunner/journal.go index c09ffcf..5ac95aa 100644 --- a/jobrunner/journal.go +++ b/jobrunner/journal.go @@ -2,6 +2,7 @@ package jobrunner import ( "encoding/json" + "errors" "fmt" "os" "path/filepath" @@ -52,7 +53,7 @@ type Journal struct { // NewJournal creates a new Journal rooted at baseDir. func NewJournal(baseDir string) (*Journal, error) { if baseDir == "" { - return nil, fmt.Errorf("journal base directory is required") + return nil, errors.New("journal base directory is required") } return &Journal{baseDir: baseDir}, nil } @@ -90,10 +91,10 @@ func sanitizePathComponent(name string) (string, error) { // Append writes a journal entry for the given signal and result. func (j *Journal) Append(signal *PipelineSignal, result *ActionResult) error { if signal == nil { - return fmt.Errorf("signal is required") + return errors.New("signal is required") } if result == nil { - return fmt.Errorf("result is required") + return errors.New("result is required") } entry := JournalEntry{ From 7ef7c3b10752bee9554b47861bb17b6a4be55783 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 16:24:05 +0000 Subject: [PATCH 2/2] chore: use %w for error wrapping Co-Authored-By: Claude Opus 4.6 --- cmd/forge/cmd_sync.go | 4 ++-- cmd/gitea/cmd_sync.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/forge/cmd_sync.go b/cmd/forge/cmd_sync.go index 9f73414..578dd7e 100644 --- a/cmd/forge/cmd_sync.go +++ b/cmd/forge/cmd_sync.go @@ -306,7 +306,7 @@ func syncPushUpstream(localPath, defaultBranch string) error { cmd := exec.Command("git", "-C", localPath, "push", "--force", "forge", refspec) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("%s", strings.TrimSpace(string(output))) + return fmt.Errorf("%s: %w", strings.TrimSpace(string(output)), err) } return nil @@ -316,7 +316,7 @@ func syncGitFetch(localPath, remote string) error { cmd := exec.Command("git", "-C", localPath, "fetch", remote) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("%s", strings.TrimSpace(string(output))) + return fmt.Errorf("%s: %w", strings.TrimSpace(string(output)), err) } return nil } diff --git a/cmd/gitea/cmd_sync.go b/cmd/gitea/cmd_sync.go index 8149b8a..f6a7c02 100644 --- a/cmd/gitea/cmd_sync.go +++ b/cmd/gitea/cmd_sync.go @@ -321,7 +321,7 @@ func pushUpstream(localPath, defaultBranch string) error { cmd := exec.Command("git", "-C", localPath, "push", "--force", "gitea", refspec) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("%s", strings.TrimSpace(string(output))) + return fmt.Errorf("%s: %w", strings.TrimSpace(string(output)), err) } return nil @@ -332,7 +332,7 @@ func gitFetch(localPath, remote string) error { cmd := exec.Command("git", "-C", localPath, "fetch", remote) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("%s", strings.TrimSpace(string(output))) + return fmt.Errorf("%s: %w", strings.TrimSpace(string(output)), err) } return nil }