gitserver

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2018 License: Apache-2.0 Imports: 14 Imported by: 1

README

go-git-server

Git server-side protocol over http in golang. This is meant to be used as a library.

The protocol itself is broken out and with a http server and repository server.

Documentation

Index

Constants

View Source
const (
	// GitServiceRecvPack constant for receive-pack
	GitServiceRecvPack = GitServiceType("git-receive-pack")
	// GitServiceUploadPack constant for upload-pack
	GitServiceUploadPack = GitServiceType("git-upload-pack")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GitHTTPService

type GitHTTPService struct {
	// contains filtered or unexported fields
}

GitHTTPService is a git http server

func NewGitHTTPService

func NewGitHTTPService(repostore repository.RepositoryStore, objstore ObjectStorage) *GitHTTPService

NewGitHTTPService instantiates the git http service with the provided repo store and object store.

func (*GitHTTPService) ListReferences

func (svr *GitHTTPService) ListReferences(w http.ResponseWriter, r *http.Request)

ListReferences per the git protocol

func (*GitHTTPService) ReceivePack

func (svr *GitHTTPService) ReceivePack(w http.ResponseWriter, r *http.Request)

ReceivePack implements the receive-pack protocol over http

func (*GitHTTPService) UploadPack

func (svr *GitHTTPService) UploadPack(w http.ResponseWriter, r *http.Request)

UploadPack implements upload-pack protocol over http

type GitHandler

type GitHandler interface {
	// clone, fetch, pull ???
	UploadPack(w http.ResponseWriter, r *http.Request)
	// push
	ReceivePack(w http.ResponseWriter, r *http.Request)
	// list refs based on receive or upload pack
	ListReferences(w http.ResponseWriter, r *http.Request)
}

GitHandler interface for git specific operations

type GitServiceType

type GitServiceType string

GitServiceType can be either receive or upload pack

type MemObjectStorage

type MemObjectStorage struct {
	// contains filtered or unexported fields
}

MemObjectStorage manages objects stores by id i.e. repo

func NewMemObjectStorage

func NewMemObjectStorage() *MemObjectStorage

func (*MemObjectStorage) GetStore

GetStore for the given id. Create one if it does not exist

type ObjectStorage

type ObjectStorage interface {
	// GetStore gets an object store given the id where the id is the namespace
	// for storage
	GetStore(string) storer.EncodedObjectStorer
}

type Protocol

type Protocol struct {
	// contains filtered or unexported fields
}

Protocol implements the git pack protocol

func NewProtocol

func NewProtocol(w io.Writer, r io.Reader) *Protocol

NewProtocol instantiates a new protocol with the given reader and writer

func (*Protocol) ListReferences

func (proto *Protocol) ListReferences(service GitServiceType, refs *repository.RepositoryReferences)

ListReferences writes the references in the pack protocol given the repository and service type

func (*Protocol) ReceivePack

func (proto *Protocol) ReceivePack(repo *repository.Repository, repostore repository.RepositoryStore, objstore storer.EncodedObjectStorer) error

ReceivePack implements the git receive pack protocol

func (*Protocol) UploadPack

func (proto *Protocol) UploadPack(store storer.EncodedObjectStorer) ([]byte, error)

UploadPack implements the git upload pack protocol

type RepoHTTPService

type RepoHTTPService struct {
	// contains filtered or unexported fields
}

func NewRepoHTTPService

func NewRepoHTTPService(store repository.RepositoryStore) *RepoHTTPService

func (*RepoHTTPService) ServeHTTP

func (svr *RepoHTTPService) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router handles routing git requests leaving the rest alone

func NewRouter

func NewRouter(gh GitHandler, rh http.Handler, uh http.Handler) *Router

NewRouter given the git handler

func (*Router) Serve

func (router *Router) Serve(addr string) error

Serve starts serving the router handlers

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP assign context to requests and ID to all requests.

type TxRef

type TxRef struct {
	// contains filtered or unexported fields
}

TxRef is a transaction to update a repo reference

Directories

Path Synopsis
Package pktline implements pkt-line format encoding used by Git's transfer protocol.
Package pktline implements pkt-line format encoding used by Git's transfer protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL