chore: replace pkg/errors with cockroachdb/errors (#8098)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit is contained in:
Copilot
2026-01-22 08:20:53 -05:00
committed by GitHub
parent ae59787ff5
commit 4ee706b2bf
96 changed files with 605 additions and 564 deletions

View File

@@ -1,11 +1,10 @@
package gitutil
import (
"fmt"
"testing"
"github.com/cockroachdb/errors"
"github.com/gogs/git-module"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
@@ -23,64 +22,64 @@ func TestModuler_PullRequestMeta(t *testing.T) {
SetMockModuleStore(t, &MockModuleStore{
remoteAdd: func(repoPath, name, url string, opts ...git.RemoteAddOptions) error {
if repoPath != headPath {
return fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
return errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
} else if name == "" {
return errors.New("empty name")
} else if url != basePath {
return fmt.Errorf("url: want %q but got %q", basePath, url)
return errors.Newf("url: want %q but got %q", basePath, url)
}
if len(opts) == 0 {
return errors.New("no options")
} else if !opts[0].Fetch {
return fmt.Errorf("opts.Fetch: want %v but got %v", true, opts[0].Fetch)
return errors.Newf("opts.Fetch: want %v but got %v", true, opts[0].Fetch)
}
return nil
},
mergeBase: func(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error) {
if repoPath != headPath {
return "", fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
return "", errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
} else if base == "" {
return "", errors.New("empty base")
} else if head != headBranch {
return "", fmt.Errorf("head: want %q but got %q", headBranch, head)
return "", errors.Newf("head: want %q but got %q", headBranch, head)
}
return mergeBase, nil
},
log: func(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error) {
if repoPath != headPath {
return nil, fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
return nil, errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
}
expRev := mergeBase + "..." + headBranch
if rev != expRev {
return nil, fmt.Errorf("rev: want %q but got %q", expRev, rev)
return nil, errors.Newf("rev: want %q but got %q", expRev, rev)
}
return commits, nil
},
diffNameOnly: func(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error) {
if repoPath != headPath {
return nil, fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
return nil, errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
} else if base == "" {
return nil, errors.New("empty base")
} else if head != headBranch {
return nil, fmt.Errorf("head: want %q but got %q", headBranch, head)
return nil, errors.Newf("head: want %q but got %q", headBranch, head)
}
if len(opts) == 0 {
return nil, errors.New("no options")
} else if !opts[0].NeedsMergeBase {
return nil, fmt.Errorf("opts.NeedsMergeBase: want %v but got %v", true, opts[0].NeedsMergeBase)
return nil, errors.Newf("opts.NeedsMergeBase: want %v but got %v", true, opts[0].NeedsMergeBase)
}
return changedFiles, nil
},
remoteRemove: func(repoPath, name string, opts ...git.RemoteRemoveOptions) error {
if repoPath != headPath {
return fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
return errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
} else if name == "" {
return errors.New("empty name")
}