Skip to content

Commit

Permalink
Merge pull request #682 from ThinkChaos/fix/transport-empty-unknown-err
Browse files Browse the repository at this point in the history
fix: don't use the `firstErrLine` when it is empty
  • Loading branch information
pjbgf committed Mar 2, 2023
2 parents a5c5c90 + c2958bf commit e051b18
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 e051b18

Please sign in to comment.