Repository: go-git/go-git (go)

Issue:
Missing error variable for "couldn't find remote ref"
If you perform a fetch and the refspecs don't match, the error that is returned contains the string "couldn't find remote ref". There is currently no built-in error to match it against so instead this workaround is required:

```go
if !strings.Contains(err.Error(), "couldn't find remote ref")
```

Perhaps this is because the error originates from the HTTP layer rather than the library itself, but it would be nice to capture this internally and pass on a matchable error so that the above snippet can be replaced with:

```go
if err != git.ErrRemoteRefNotFound
```

Pull request description:
git: remote, replace NoMatchingRefSpecError with ErrRemoteRefNotFound, Fixes #1480

Patch:
diff --git a/remote.go b/remote.go
index 69db94e4..b1fcafe2 100644
--- a/remote.go
+++ b/remote.go
@@ -35,21 +35,9 @@ var (
 	ErrForceNeeded           = errors.New("some refs were not updated")
 	ErrExactSHA1NotSupported = errors.New("server does not support exact SHA1 refspec")
 	ErrEmptyUrls             = errors.New("URLs cannot be empty")
+	ErrRemoteRefNotFound     = errors.New("couldn't find remote ref")
 )
 
-type NoMatchingRefSpecError struct {
-	refSpec config.RefSpec
-}
-
-func (e NoMatchingRefSpecError) Error() string {
-	return fmt.Sprintf("couldn't find remote ref %q", e.refSpec.Src())
-}
-
-func (e NoMatchingRefSpecError) Is(target error) bool {
-	_, ok := target.(NoMatchingRefSpecError)
-	return ok
-}
-
 const (
 	// This describes the maximum number of commits to walk when
 	// computing the haves to send to a server, for each ref in the
@@ -978,7 +966,7 @@ func doCalculateRefs(
 	}
 
 	if !matched && !s.IsWildcard() {
-		return nil, NoMatchingRefSpecError{refSpec: s}
+		return nil, fmt.Errorf("%w: %s", ErrRemoteRefNotFound, s.Src())
 	}
 
 	return refList, ret


Test patch:
diff --git a/remote_test.go b/remote_test.go
index 1f52a1cc..b2232a1f 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -217,8 +217,7 @@ func (s *RemoteSuite) TestFetchNonExistentReference() {
 		},
 	})
 
-	s.ErrorContains(err, "couldn't find remote ref")
-	s.True(errors.Is(err, NoMatchingRefSpecError{}))
+	s.ErrorIs(err, ErrRemoteRefNotFound)
 }
 
 func (s *RemoteSuite) TestFetchContext() {