@@ -5,14 +5,16 @@ import (
55 "bytes"
66 "context"
77 "fmt"
8- "io"
8+ goio "io"
99 "os"
1010 "os/exec"
1111 "path/filepath"
1212 "slices"
1313 "strconv"
1414 "strings"
1515 "sync"
16+
17+ coreerr "forge.lthn.ai/core/go-log"
1618)
1719
1820// RepoStatus represents the git status of a single repository.
@@ -81,7 +83,7 @@ func getStatus(ctx context.Context, path, name string) RepoStatus {
8183
8284 // Validate path to prevent directory traversal
8385 if ! filepath .IsAbs (path ) {
84- status .Error = fmt . Errorf ( " path must be absolute: %s" , path )
86+ status .Error = coreerr . E ( "git.getStatus" , " path must be absolute: " + path , nil )
8587 return status
8688 }
8789
@@ -200,7 +202,7 @@ func gitInteractive(ctx context.Context, dir string, args ...string) error {
200202
201203 // Capture stderr for error reporting while also showing it
202204 var stderr bytes.Buffer
203- cmd .Stderr = io .MultiWriter (os .Stderr , & stderr )
205+ cmd .Stderr = goio .MultiWriter (os .Stderr , & stderr )
204206
205207 if err := cmd .Run (); err != nil {
206208 return & GitError {
@@ -272,6 +274,9 @@ func gitCommand(ctx context.Context, dir string, args ...string) (string, error)
272274 return stdout .String (), nil
273275}
274276
277+ // Compile-time interface checks.
278+ var _ error = (* GitError )(nil )
279+
275280// GitError wraps a git command error with stderr output and command context.
276281type GitError struct {
277282 Args []string
@@ -285,9 +290,12 @@ func (e *GitError) Error() string {
285290 stderr := strings .TrimSpace (e .Stderr )
286291
287292 if stderr != "" {
288- return fmt .Errorf ("git command %q failed: %s" , cmd , stderr ).Error ()
293+ return fmt .Sprintf ("git command %q failed: %s" , cmd , stderr )
294+ }
295+ if e .Err != nil {
296+ return fmt .Sprintf ("git command %q failed: %v" , cmd , e .Err )
289297 }
290- return fmt .Errorf ("git command %q failed: %w " , cmd , e . Err ). Error ( )
298+ return fmt .Sprintf ("git command %q failed" , cmd )
291299}
292300
293301// Unwrap returns the underlying error for error chain inspection.
0 commit comments