mirror of https://github.com/golang/go.git
cmd/go/internal/modfetch: distinguish "unsupported" errors from RecentTag
CL 426079 started checking errors from RecentTag. Unfortunately, we forgot to run "-longtest" SlowBots, and it turns out to have broken non-short tests for non-git VCS implementations, because those don't implement the RecentTag method. Updates #53935. Change-Id: I5935f2f4b3f684515e99e8bf70a840154c36249f Reviewed-on: https://go-review.googlesource.com/c/go/+/426495 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
2113fefe7d
commit
7b689dcbef
|
|
@ -201,6 +201,19 @@ func (noCommitsError) Is(err error) bool {
|
|||
return err == fs.ErrNotExist
|
||||
}
|
||||
|
||||
// ErrUnsupported indicates that a requested operation cannot be performed,
|
||||
// because it is unsupported. This error indicates that there is no alternative
|
||||
// way to perform the operation.
|
||||
//
|
||||
// TODO(#41198): Remove this declaration and use errors.ErrUnsupported instead.
|
||||
var ErrUnsupported = unsupportedOperationError{}
|
||||
|
||||
type unsupportedOperationError struct{}
|
||||
|
||||
func (unsupportedOperationError) Error() string {
|
||||
return "unsupported operation"
|
||||
}
|
||||
|
||||
// AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.
|
||||
func AllHex(rev string) bool {
|
||||
for i := 0; i < len(rev); i++ {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ type VCSError struct {
|
|||
|
||||
func (e *VCSError) Error() string { return e.Err.Error() }
|
||||
|
||||
func (e *VCSError) Unwrap() error { return e.Err }
|
||||
|
||||
func vcsErrorf(format string, a ...any) error {
|
||||
return &VCSError{Err: fmt.Errorf(format, a...)}
|
||||
}
|
||||
|
|
@ -290,10 +292,8 @@ func (r *vcsRepo) loadBranches() {
|
|||
}
|
||||
}
|
||||
|
||||
var ErrNoRepoHash = errors.New("RepoHash not supported")
|
||||
|
||||
func (r *vcsRepo) CheckReuse(old *Origin, subdir string) error {
|
||||
return fmt.Errorf("vcs %s does not implement CheckReuse", r.cmd.vcs)
|
||||
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, ErrUnsupported)
|
||||
}
|
||||
|
||||
func (r *vcsRepo) Tags(prefix string) (*Tags, error) {
|
||||
|
|
@ -417,7 +417,7 @@ func (r *vcsRepo) RecentTag(rev, prefix string, allowed func(string) bool) (tag
|
|||
}
|
||||
defer unlock()
|
||||
|
||||
return "", vcsErrorf("RecentTag not implemented")
|
||||
return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, ErrUnsupported)
|
||||
}
|
||||
|
||||
func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
|
||||
|
|
@ -427,12 +427,12 @@ func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
|
|||
}
|
||||
defer unlock()
|
||||
|
||||
return false, vcsErrorf("DescendsFrom not implemented")
|
||||
return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, ErrUnsupported)
|
||||
}
|
||||
|
||||
func (r *vcsRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) {
|
||||
if r.cmd.readZip == nil && r.cmd.doReadZip == nil {
|
||||
return nil, vcsErrorf("ReadZip not implemented for %s", r.cmd.vcs)
|
||||
return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, ErrUnsupported)
|
||||
}
|
||||
|
||||
unlock, err := r.mu.Lock()
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ func (r *codeRepo) convert(info *codehost.RevInfo, statVers string) (*RevInfo, e
|
|||
}
|
||||
if pseudoBase == "" {
|
||||
tag, err := r.code.RecentTag(info.Name, tagPrefix, tagAllowed)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, codehost.ErrUnsupported) {
|
||||
return nil, err
|
||||
}
|
||||
if tag != "" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue