diff options
-rw-r--r-- | COMPATIBILITY.md | 2 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | plumbing/transport/server/receive_pack_test.go | 30 | ||||
-rw-r--r-- | plumbing/transport/server/server.go | 12 |
4 files changed, 40 insertions, 8 deletions
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 395088b..2a72b50 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -101,7 +101,7 @@ is supported by go-git. | http(s):// (smart) | ✔ | | git:// | ✔ | | ssh:// | ✔ | -| file:// | ✔ | +| file:// | partial | Warning: this is not pure Golang. This shells out to the `git` binary. | | custom | ✔ | | **other features** | | gitignore | ✔ | @@ -1,5 +1,5 @@ ![go-git logo](https://cdn.rawgit.com/src-d/artwork/02036484/go-git/files/go-git-github-readme-header.png) -[![GoDoc](https://godoc.org/github.com/go-git/go-git/v5?status.svg)](https://pkg.go.dev/github.com/go-git/go-git/v5) [![Build Status](https://github.com/go-git/go-git/workflows/Test%20&%20Coverage/badge.svg)](https://github.com/go-git/go-git/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/go-git/go-git)](https://goreportcard.com/report/github.com/go-git/go-git) +[![GoDoc](https://godoc.org/github.com/go-git/go-git/v5?status.svg)](https://pkg.go.dev/github.com/go-git/go-git/v5) [![Build Status](https://github.com/go-git/go-git/workflows/Test/badge.svg)](https://github.com/go-git/go-git/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/go-git/go-git)](https://goreportcard.com/report/github.com/go-git/go-git) *go-git* is a highly extensible git implementation library written in **pure Go**. @@ -12,7 +12,7 @@ Project Status After the legal issues with the [`src-d`](https://github.com/src-d) organization, the lack of update for four months and the requirement to make a hard fork, the project is **now back to normality**. -The project is currently actively maintained by individual contributors, including several of the original authors, but also backed by a new company `gitsigth` where `go-git` is a critical component used at scale. +The project is currently actively maintained by individual contributors, including several of the original authors, but also backed by a new company, [gitsight](https://github.com/gitsight), where `go-git` is a critical component used at scale. Comparison with git diff --git a/plumbing/transport/server/receive_pack_test.go b/plumbing/transport/server/receive_pack_test.go index de072f3..2c5b0ae 100644 --- a/plumbing/transport/server/receive_pack_test.go +++ b/plumbing/transport/server/receive_pack_test.go @@ -1,8 +1,13 @@ package server_test import ( + "context" + + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/protocol/packp" "github.com/go-git/go-git/v5/plumbing/transport" + fixtures "github.com/go-git/go-git-fixtures/v4" . "gopkg.in/check.v1" ) @@ -31,3 +36,28 @@ func (s *ReceivePackSuite) TestAdvertisedReferencesNotExists(c *C) { c.Assert(err, Equals, transport.ErrRepositoryNotFound) c.Assert(r, IsNil) } + +func (s *ReceivePackSuite) TestReceivePackWithNilPackfile(c *C) { + endpoint := s.Endpoint + auth := s.EmptyAuth + + fixture := fixtures.Basic().ByTag("packfile").One() + req := packp.NewReferenceUpdateRequest() + req.Commands = []*packp.Command{ + {Name: "refs/heads/newbranch", Old: plumbing.NewHash(fixture.Head), New: plumbing.ZeroHash}, + } + // default is already nil, but be explicit since this is what the test is for + req.Packfile = nil + + comment := Commentf( + "failed with ep=%s fixture=%s", + endpoint.String(), fixture.URL, + ) + + r, err := s.Client.NewReceivePackSession(endpoint, auth) + c.Assert(err, IsNil, comment) + defer func() { c.Assert(r.Close(), IsNil, comment) }() + + report, err := r.ReceivePack(context.Background(), req) + c.Assert(report, IsNil, comment) +} diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go index 71845e3..727f902 100644 --- a/plumbing/transport/server/server.go +++ b/plumbing/transport/server/server.go @@ -243,11 +243,13 @@ func (s *rpSession) ReceivePack(ctx context.Context, req *packp.ReferenceUpdateR //TODO: Implement 'atomic' update of references. - r := ioutil.NewContextReadCloser(ctx, req.Packfile) - if err := s.writePackfile(r); err != nil { - s.unpackErr = err - s.firstErr = err - return s.reportStatus(), err + if req.Packfile != nil { + r := ioutil.NewContextReadCloser(ctx, req.Packfile) + if err := s.writePackfile(r); err != nil { + s.unpackErr = err + s.firstErr = err + return s.reportStatus(), err + } } s.updateReferences(req) |