diff options
author | Santiago M. Mola <santi@mola.io> | 2017-01-04 11:18:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-04 11:18:41 +0100 |
commit | 841abfb7dc640755c443432064252907e3e55c95 (patch) | |
tree | 8af69dcd3b301a10a3e493e2cd805cdec6dcaecd /plumbing/transport/common.go | |
parent | 90d67bb648ae32d5b1a0f7b1af011da6dfb24315 (diff) | |
download | go-git-841abfb7dc640755c443432064252907e3e55c95.tar.gz |
server: add git server implementation (#190)
* server: add generic server implementation (transport-independent),
both for git-upload-pack and git-receive-pack.
* server: move internal functions to internal/common.
* cli: add git-receive-pack and git-upload-pack implementations.
* format/packfile: add UpdateObjectStorage function, extracted from
Remote.
* transport: implement tranport RPC-like, only with git-upload-pack and
git-receive-pack methods. Client renamed to Transport.
* storer: add storer.Storer interface.
* protocol/packp: add UploadPackResponse constructor with packfile.
* protocol/packp: fix UploadPackResponse encoding, add tests.
* protocol/packp/capability: implement All.
Diffstat (limited to 'plumbing/transport/common.go')
-rw-r--r-- | plumbing/transport/common.go | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/plumbing/transport/common.go b/plumbing/transport/common.go index 83fd5a3..00e8a30 100644 --- a/plumbing/transport/common.go +++ b/plumbing/transport/common.go @@ -37,21 +37,23 @@ const ( ReceivePackServiceName = "git-receive-pack" ) -// Client can initiate git-fetch-pack and git-send-pack processes. -type Client interface { - // NewFetchPackSession starts a git-fetch-pack session for an endpoint. - NewFetchPackSession(Endpoint) (FetchPackSession, error) - // NewSendPackSession starts a git-send-pack session for an endpoint. - NewSendPackSession(Endpoint) (SendPackSession, error) +// Transport can initiate git-upload-pack and git-receive-pack processes. +// It is implemented both by the client and the server, making this a RPC. +type Transport interface { + // NewUploadPackSession starts a git-upload-pack session for an endpoint. + NewUploadPackSession(Endpoint) (UploadPackSession, error) + // NewReceivePackSession starts a git-receive-pack session for an endpoint. + NewReceivePackSession(Endpoint) (ReceivePackSession, error) } type Session interface { - SetAuth(auth AuthMethod) error // AdvertisedReferences retrieves the advertised references for a // repository. // If the repository does not exist, returns ErrRepositoryNotFound. // If the repository exists, but is empty, returns ErrEmptyRemoteRepository. AdvertisedReferences() (*packp.AdvRefs, error) + //TODO: Move to Client level. + SetAuth(auth AuthMethod) error io.Closer } @@ -60,26 +62,30 @@ type AuthMethod interface { Name() string } -// FetchPackSession represents a git-fetch-pack session. -// A git-fetch-pack session has two steps: reference discovery -// (`AdvertisedReferences` function) and fetching pack (`FetchPack` function). -// In that order. -type FetchPackSession interface { +// UploadPackSession represents a git-upload-pack session. +// A git-upload-pack session has two steps: reference discovery +// (AdvertisedReferences) and uploading pack (UploadPack). +type UploadPackSession interface { Session - // FetchPack takes a request and returns a reader for the packfile - // received from the server. - FetchPack(*packp.UploadPackRequest) (*packp.UploadPackResponse, error) + // UploadPack takes a git-upload-pack request and returns a response, + // including a packfile. Don't be confused by terminology, the client + // side of a git-upload-pack is called git-fetch-pack, although here + // the same interface is used to make it RPC-like. + UploadPack(*packp.UploadPackRequest) (*packp.UploadPackResponse, error) } -// SendPackSession represents a git-send-pack session. -// A git-send-pack session has two steps: reference discovery -// (`AdvertisedReferences` function) and sending pack (`SendPack` function). +// ReceivePackSession represents a git-receive-pack session. +// A git-receive-pack session has two steps: reference discovery +// (AdvertisedReferences) and receiving pack (ReceivePack). // In that order. -type SendPackSession interface { +type ReceivePackSession interface { Session - // UpdateReferences sends an update references request and a packfile - // reader and returns a ReportStatus and error. - SendPack(*packp.ReferenceUpdateRequest) (*packp.ReportStatus, error) + // ReceivePack sends an update references request and a packfile + // reader and returns a ReportStatus and error. Don't be confused by + // terminology, the client side of a git-receive-pack is called + // git-send-pack, although here the same interface is used to make it + // RPC-like. + ReceivePack(*packp.ReferenceUpdateRequest) (*packp.ReportStatus, error) } type Endpoint url.URL |