git

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthed represents unauthorized access.
	ErrNotAuthed = errors.New("you are not authorized to do this")

	// ErrSystemMalfunction represents a general system error returned to clients.
	ErrSystemMalfunction = errors.New("something went wrong")

	// ErrInvalidRepo represents an attempt to access a non-existent repo.
	ErrInvalidRepo = errors.New("invalid repo")

	// ErrInvalidRequest represents an invalid request.
	ErrInvalidRequest = errors.New("invalid request")

	// ErrMaxConnections represents a maximum connection limit being reached.
	ErrMaxConnections = errors.New("too many connections, try again later")

	// ErrTimeout is returned when the maximum read timeout is exceeded.
	ErrTimeout = errors.New("I/O timeout reached")
)

Functions

func EnsureDefaultBranch

func EnsureDefaultBranch(ctx context.Context, scmd ServiceCommand) error

EnsureDefaultBranch ensures the repo has a default branch. It will prefer choosing "main" or "master" if available.

func EnsureWithin

func EnsureWithin(reposDir string, repo string) error

EnsureWithin ensures the given repo is within the repos directory.

func LFSAuthenticate

func LFSAuthenticate(ctx context.Context, cmd ServiceCommand) error

LFSAuthenticate implements teh Git LFS SSH authentication command. Context must have *config.Config, *log.Logger, proto.User. cmd.Args should have the repo path and operation as arguments.

func LFSTransfer

func LFSTransfer(ctx context.Context, cmd ServiceCommand) error

LFSTransfer is a Git LFS transfer service handler. ctx is expected to have proto.User, *backend.Backend, *log.Logger, *config.Config, *db.DB, and store.Store. The first arg in cmd.Args should be the repo path. The second arg in cmd.Args should be the LFS operation (download or upload).

func ReceivePack

func ReceivePack(ctx context.Context, cmd ServiceCommand) error

ReceivePack runs the git receive-pack protocol against the provided repo.

func UploadArchive

func UploadArchive(ctx context.Context, cmd ServiceCommand) error

UploadArchive runs the git upload-archive protocol against the provided repo.

func UploadPack

func UploadPack(ctx context.Context, cmd ServiceCommand) error

UploadPack runs the git upload-pack protocol against the provided repo.

func WritePktline

func WritePktline(w io.Writer, v ...interface{}) error

WritePktline encodes and writes a pktline to the given writer.

func WritePktlineErr

func WritePktlineErr(w io.Writer, err error) error

WritePktlineErr writes an error pktline to the given writer.

Types

type LFSLock

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

LFSLock is a Git LFS lock object. It implements transfer.Lock.

func (*LFSLock) AsArguments

func (l *LFSLock) AsArguments() []string

AsArguments implements transfer.Lock.

func (*LFSLock) AsLockSpec

func (l *LFSLock) AsLockSpec(ownerID bool) ([]string, error)

AsLockSpec implements transfer.Lock.

func (*LFSLock) FormattedTimestamp

func (l *LFSLock) FormattedTimestamp() string

FormattedTimestamp implements transfer.Lock.

func (*LFSLock) ID

func (l *LFSLock) ID() string

ID implements transfer.Lock.

func (*LFSLock) OwnerName

func (l *LFSLock) OwnerName() string

OwnerName implements transfer.Lock.

func (*LFSLock) Path

func (l *LFSLock) Path() string

Path implements transfer.Lock.

func (*LFSLock) Unlock

func (l *LFSLock) Unlock() error

Unlock implements transfer.Lock.

type Service

type Service string

Service is a Git daemon service.

const (
	// UploadPackService is the upload-pack service.
	UploadPackService Service = "git-upload-pack"
	// UploadArchiveService is the upload-archive service.
	UploadArchiveService Service = "git-upload-archive"
	// ReceivePackService is the receive-pack service.
	ReceivePackService Service = "git-receive-pack"
	// LFSTransferService is the LFS transfer service.
	LFSTransferService Service = "git-lfs-transfer"
	// LFSAuthenticateService is the LFS authenticate service.
	LFSAuthenticateService = "git-lfs-authenticate"
)

func (Service) Handler

func (s Service) Handler(ctx context.Context, cmd ServiceCommand) error

Handler is the service handler.

func (Service) Name

func (s Service) Name() string

Name returns the name of the service.

func (Service) String

func (s Service) String() string

String returns the string representation of the service.

type ServiceCommand

type ServiceCommand struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Dir    string
	Env    []string
	Args   []string

	// Modifier functions
	CmdFunc func(*exec.Cmd)
}

ServiceCommand is used to run a git service command.

type ServiceHandler

type ServiceHandler func(ctx context.Context, cmd ServiceCommand) error

ServiceHandler is a git service command handler.

Jump to

Keyboard shortcuts

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