aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-03-02 20:21:25 +0000
committerGitHub <noreply@github.com>2023-03-02 20:21:25 +0000
commite051b182abd14eb658d872bc1cfdabbdc056bbbd (patch)
tree3dacaec75cff61064f73a4e64cc5d4aaaa60ef3a /plumbing/transport
parenta5c5c900a860ec53ef9bb891e172ae30763e1084 (diff)
parentc2958bf730224cc3672e2105faa1879ec5f21cee (diff)
downloadgo-git-e051b182abd14eb658d872bc1cfdabbdc056bbbd.tar.gz
Merge pull request #682 from ThinkChaos/fix/transport-empty-unknown-err
fix: don't use the `firstErrLine` when it is empty
Diffstat (limited to 'plumbing/transport')
-rw-r--r--plumbing/transport/internal/common/common.go2
-rw-r--r--plumbing/transport/internal/common/common_test.go14
2 files changed, 15 insertions, 1 deletions
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index d0e9a29..b2c2fee 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -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
}
diff --git a/plumbing/transport/internal/common/common_test.go b/plumbing/transport/internal/common/common_test.go
index c60ef3b..affa787 100644
--- a/plumbing/transport/internal/common/common_test.go
+++ b/plumbing/transport/internal/common/common_test.go
@@ -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)
+}