Remove unused ErrNoGitRepository error

This commit is contained in:
Tyler McGoffin 2025-01-31 14:49:38 -08:00
parent 601cf88852
commit e428b9c66c
3 changed files with 9 additions and 9 deletions

View file

@ -6,7 +6,6 @@ import (
"errors"
"io"
"os/exec"
"strings"
"github.com/cli/cli/v2/internal/run"
)
@ -49,10 +48,6 @@ func (gc *Command) Output() ([]byte, error) {
ge.Stderr = string(exitError.Stderr)
ge.ExitCode = exitError.ExitCode()
}
if strings.Contains(ge.Stderr, "fatal: not a git repository") {
ge.err = ErrNoGitRepository
}
err = &ge
}
return out, err

View file

@ -18,7 +18,7 @@ func TestOutput(t *testing.T) {
exitCode int
stdout string
stderr string
wantErr error
wantErr *GitError
}{
{
name: "successful command",
@ -32,7 +32,11 @@ func TestOutput(t *testing.T) {
stdout: "",
stderr: "fatal: not a git repository (or any of the parent directories): .git",
exitCode: 128,
wantErr: ErrNoGitRepository,
wantErr: &GitError{
ExitCode: 128,
Stderr: "fatal: not a git repository (or any of the parent directories): .git",
err: &exec.ExitError{},
},
},
}
@ -50,7 +54,9 @@ func TestOutput(t *testing.T) {
require.Error(t, err)
var gitError *GitError
require.ErrorAs(t, err, &gitError)
assert.Equal(t, tt.wantErr, gitError.err)
assert.Equal(t, tt.wantErr.ExitCode, gitError.ExitCode)
assert.Equal(t, tt.wantErr.Stderr, gitError.Stderr)
assert.Equal(t, tt.wantErr.Error(), gitError.Error())
} else {
require.NoError(t, err)
}

View file

@ -7,7 +7,6 @@ import (
// ErrNotOnAnyBranch indicates that the user is in detached HEAD state.
var ErrNotOnAnyBranch = errors.New("git: not on any branch")
var ErrNoGitRepository = errors.New("git: not in a git repository")
type NotInstalled struct {
message string