Skip to content

Commit

Permalink
cmd/go/internal/modfetch: use errors.ErrUnsupported
Browse files Browse the repository at this point in the history
CL 473935 added errors.ErrUnsupported, let's use it.

Updates #41198

Change-Id: If6534d19cb31ca979ff00d529bd6bdfc964a616d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476135
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
  • Loading branch information
tklauser authored and gopherbot committed Mar 14, 2023
1 parent 08c3299 commit ebf8e26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
13 changes: 0 additions & 13 deletions src/cmd/go/internal/modfetch/codehost/codehost.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,6 @@ 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++ {
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/go/internal/modfetch/codehost/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (r *vcsRepo) loadBranches() {
}

func (r *vcsRepo) CheckReuse(old *Origin, subdir string) error {
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, ErrUnsupported)
return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, errors.ErrUnsupported)
}

func (r *vcsRepo) Tags(prefix string) (*Tags, error) {
Expand Down Expand Up @@ -412,7 +412,7 @@ func (r *vcsRepo) RecentTag(rev, prefix string, allowed func(string) bool) (tag
}
defer unlock()

return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, ErrUnsupported)
return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, errors.ErrUnsupported)
}

func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
Expand All @@ -422,12 +422,12 @@ func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
}
defer unlock()

return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, ErrUnsupported)
return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, errors.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("vcs %s: ReadZip: %w", r.cmd.vcs, ErrUnsupported)
return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, errors.ErrUnsupported)
}

unlock, err := r.mu.Lock()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modfetch/coderepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 && !errors.Is(err, codehost.ErrUnsupported) {
if err != nil && !errors.Is(err, errors.ErrUnsupported) {
return nil, err
}
if tag != "" {
Expand Down

0 comments on commit ebf8e26

Please sign in to comment.