Skip to content

Commit

Permalink
fix: don't use the firstErrLine when it is empty
Browse files Browse the repository at this point in the history
Returning `nil` causes `handleAdvRefDecodeError` to fall back
to `io.ErrUnexpectedEOF`.
  • Loading branch information
ThinkChaos committed Feb 22, 2023
1 parent 7ab4957 commit c2958bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plumbing/transport/internal/common/common.go
Expand Up @@ -374,7 +374,7 @@ func (s *session) checkNotFoundError() error {
case <-t.C:
return ErrTimeoutExceeded
case line, ok := <-s.firstErrLine:
if !ok {
if !ok || len(line) == 0 {
return nil
}

Expand Down
14 changes: 14 additions & 0 deletions plumbing/transport/internal/common/common_test.go
Expand Up @@ -76,3 +76,17 @@ func (s *CommonSuite) TestIsRepoNotFoundErrorForGogsAccessDenied(c *C) {

c.Assert(isRepoNotFound, Equals, true)
}

func (s *CommonSuite) TestCheckNotFoundError(c *C) {
firstErrLine := make(chan string, 1)

session := session{
firstErrLine: firstErrLine,
}

firstErrLine <- ""

err := session.checkNotFoundError()

c.Assert(err, IsNil)
}

0 comments on commit c2958bf

Please sign in to comment.