Rename error variables and types to follow errname linter conventions: - Exported sentinels: ErrXxx - Unexported sentinels: errXxx - Exported error types: XxxError - Unexported error types: xxxError Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 lines
672 B
Go
39 lines
672 B
Go
package git
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// ErrNotOnAnyBranch indicates that the user is in detached HEAD state.
|
|
var ErrNotOnAnyBranch = errors.New("git: not on any branch")
|
|
|
|
type NotInstalledError struct {
|
|
message string
|
|
err error
|
|
}
|
|
|
|
func (e *NotInstalledError) Error() string {
|
|
return e.message
|
|
}
|
|
|
|
func (e *NotInstalledError) Unwrap() error {
|
|
return e.err
|
|
}
|
|
|
|
type GitError struct {
|
|
ExitCode int
|
|
Stderr string
|
|
err error
|
|
}
|
|
|
|
func (ge *GitError) Error() string {
|
|
if ge.Stderr == "" {
|
|
return fmt.Sprintf("failed to run git: %v", ge.err)
|
|
}
|
|
return fmt.Sprintf("failed to run git: %s", ge.Stderr)
|
|
}
|
|
|
|
func (ge *GitError) Unwrap() error {
|
|
return ge.err
|
|
}
|