gitserver

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 25 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyCommit

func CreateEmptyCommit(repo *gogit.Repository) error

func ExtractTar

func ExtractTar(t *testing.T, tarfile string, dir string)

func OpenGitRepositoryFromArchive

func OpenGitRepositoryFromArchive(t *testing.T, tarfile, tempdir string) *gogit.Repository

func OpenGitRepositoryFromArchiveWithWorktree

func OpenGitRepositoryFromArchiveWithWorktree(t *testing.T, tarfile, path string) *gogit.Repository

func ServeExistingRepository

func ServeExistingRepository(t *testing.T, repo *gogit.Repository) string

func ServeGitRepository

func ServeGitRepository(t *testing.T, tarfile, tempdir string) (*gogit.Repository, string)

Types

type DynamicRepos

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

func NewDynamicRepos

func NewDynamicRepos(baseDir string, gitRepoOptions []GitRepoOption) *DynamicRepos

func (*DynamicRepos) FindRepo

func (r *DynamicRepos) FindRepo(ctx context.Context, id string) (*Repo, error)

type GitHash

type GitHash = plumbing.Hash

type GitRepoOption

type GitRepoOption interface {
	// contains filtered or unexported methods
}

GitRepoOption is implemented by configuration settings for git repository.

func WithBasicAuth

func WithBasicAuth(username, password string) GitRepoOption

type GitServer

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

GitServer is a mock git server implementing "just enough" of the git protocol

func NewGitServer

func NewGitServer(repos Repos, opts ...GitServerOption) (*GitServer, error)

NewGitServer constructs a GitServer backed by the specified repo.

func (*GitServer) ListenAndServe

func (s *GitServer) ListenAndServe(ctx context.Context, listen string, addressChannel chan<- net.Addr) error

ListenAndServe starts the git server on "listen". The address we actually start listening on will be posted to addressChannel

func (*GitServer) ServeHTTP

func (s *GitServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the entrypoint for http requests.

type GitServerOption

type GitServerOption interface {
	// contains filtered or unexported methods
}

type PacketLineWriter

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

PacketLineWriter implements the git protocol line framing, with deferred error handling.

func NewPacketLineWriter

func NewPacketLineWriter(w io.Writer) *PacketLineWriter

NewPacketLineWriter constructs a PacketLineWriter

func (*PacketLineWriter) Flush

func (w *PacketLineWriter) Flush() error

Flush writes any buffered data, and returns an error if one has accumulated.

func (*PacketLineWriter) WriteLine

func (w *PacketLineWriter) WriteLine(s string)

WriteLine frames and writes a line, accumulating errors until Flush is called.

func (*PacketLineWriter) WriteZeroPacketLine

func (w *PacketLineWriter) WriteZeroPacketLine()

WriteZeroPacketLine writes a special "0000" line - often used to indicate the end of a block in the git protocol

type RefUpdate

type RefUpdate struct {
	From GitHash
	To   GitHash
	Ref  string
}

RefUpdate stores requested tag/branch updates

type Repo

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

Repo manages a single git repository

func NewRepo

func NewRepo(gogit *gogit.Repository, options ...GitRepoOption) (*Repo, error)

NewRepo constructs an instance of Repo

type Repos

type Repos interface {
	FindRepo(ctx context.Context, id string) (*Repo, error)
}

type StaticRepos

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

StaticRepos holds multiple registered git repositories

func NewStaticRepos

func NewStaticRepos() *StaticRepos

NewStaticRepos constructs an instance of StaticRepos

func (*StaticRepos) Add

func (r *StaticRepos) Add(id string, repo *Repo) error

Add registers a git repository under the specified id

func (*StaticRepos) FindRepo

func (r *StaticRepos) FindRepo(ctx context.Context, id string) (*Repo, error)

FindRepo returns a repo registered under the specified id, or nil if none is registered.

Jump to

Keyboard shortcuts

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