git

package
v0.0.0-...-f8ac4ba Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Add(filename string) error
	Remove(filename string) error
	Clone(ctx context.Context) error
	Commit(message string, opts ...CommitOpt) error
	Push(ctx context.Context) error
	Pull(ctx context.Context, branch string) error
	Status() error
	Init() error
	Branch(name string) error
	ValidateRemoteExists(ctx context.Context) error
	// filename for all the functions should be the full path from the repo base
	CreateFile(filename string, contents []byte) error
	CopyFile(curFile, dstFile string) error
	MoveFile(curFile, dstFile string) error
	DeleteFile(filename string) error
	ModifyFile(filename string, contents []byte) error
	ReadFile(filename string) (string, error)
	ReadFiles(foldername string) (map[string]string, error)
}

func NewClient

func NewClient(opts ...Opt) Client

type CommitOpt

type CommitOpt func(signature *object.Signature)

func WithEmail

func WithEmail(email string) CommitOpt

func WithUser

func WithUser(user string) CommitOpt

type GoGit

type GoGit interface {
	AddGlob(f string, w *gogit.Worktree) error
	Checkout(w *gogit.Worktree, opts *gogit.CheckoutOptions) error
	Clone(ctx context.Context, dir string, repoUrl string, auth transport.AuthMethod) (*gogit.Repository, error)
	CloneInMemory(ctx context.Context, repourl string, auth transport.AuthMethod) (*gogit.Repository, error)
	Commit(m string, sig *object.Signature, w *gogit.Worktree) (plumbing.Hash, error)
	CommitObject(r *gogit.Repository, h plumbing.Hash) (*object.Commit, error)
	Create(r *gogit.Repository, url string) (*gogit.Remote, error)
	CreateBranch(r *gogit.Repository, config *config.Branch) error
	Head(r *gogit.Repository) (*plumbing.Reference, error)
	NewRemote(url, remoteName string) *gogit.Remote
	Init(dir string) (*gogit.Repository, error)
	OpenRepo() (*gogit.Repository, error)
	OpenWorktree(r *gogit.Repository) (*gogit.Worktree, error)
	PushWithContext(ctx context.Context, r *gogit.Repository, auth transport.AuthMethod) error
	PullWithContext(ctx context.Context, w *gogit.Worktree, auth transport.AuthMethod, ref plumbing.ReferenceName) error
	ListRemotes(r *gogit.Repository, auth transport.AuthMethod) ([]*plumbing.Reference, error)
	ListWithContext(ctx context.Context, r *gogit.Remote, auth transport.AuthMethod) ([]*plumbing.Reference, error)
	Remove(f string, w *gogit.Worktree) (plumbing.Hash, error)
	SetRepositoryReference(r *gogit.Repository, p *plumbing.Reference) error
	WithRepositoryDirectory(dir string)
}

type GogitClient

type GogitClient struct {
	Auth          transport.AuthMethod
	Client        GoGit
	Retrier       *retrier.Retrier
	RepoDirectory *string
	RepoUrl       string
	InMemory      bool
}

func (*GogitClient) Add

func (g *GogitClient) Add(filename string) error

func (*GogitClient) Branch

func (g *GogitClient) Branch(name string) error

func (*GogitClient) Clone

func (g *GogitClient) Clone(ctx context.Context) error

func (*GogitClient) Commit

func (g *GogitClient) Commit(message string, opts ...CommitOpt) error

func (*GogitClient) CopyFile

func (g *GogitClient) CopyFile(curPath, dstPath string) error

func (*GogitClient) CreateFile

func (g *GogitClient) CreateFile(filename string, contents []byte) error

func (*GogitClient) DeleteFile

func (g *GogitClient) DeleteFile(filename string) error

func (*GogitClient) Init

func (g *GogitClient) Init() error

func (*GogitClient) ModifyFile

func (g *GogitClient) ModifyFile(filename string, contents []byte) error

func (*GogitClient) MoveFile

func (g *GogitClient) MoveFile(curPath, dstPath string) error

func (*GogitClient) Pull

func (g *GogitClient) Pull(ctx context.Context, branch string) error

func (*GogitClient) Push

func (g *GogitClient) Push(ctx context.Context) error

func (*GogitClient) ReadFile

func (g *GogitClient) ReadFile(filename string) (string, error)

func (*GogitClient) ReadFiles

func (g *GogitClient) ReadFiles(foldername string) (map[string]string, error)

func (*GogitClient) Remove

func (g *GogitClient) Remove(filename string) error

func (*GogitClient) Status

func (g *GogitClient) Status() error

func (*GogitClient) ValidateRemoteExists

func (g *GogitClient) ValidateRemoteExists(ctx context.Context) error

type Opt

type Opt func(*GogitClient)

func WithAuth

func WithAuth(auth transport.AuthMethod) Opt

func WithInMemoryFilesystem

func WithInMemoryFilesystem() Opt

func WithRepositoryDirectory

func WithRepositoryDirectory(repoDir string) Opt

func WithRepositoryUrl

func WithRepositoryUrl(repoUrl string) Opt

type RemoteBranchDoesNotExistError

type RemoteBranchDoesNotExistError struct {
	Repository string
	Branch     string
}

func (*RemoteBranchDoesNotExistError) Error

type RepositoryDoesNotExistError

type RepositoryDoesNotExistError struct {
	Err error
	// contains filtered or unexported fields
}

func (*RepositoryDoesNotExistError) Error

type RepositoryIsEmptyError

type RepositoryIsEmptyError struct {
	Repository string
}

func (*RepositoryIsEmptyError) Error

func (e *RepositoryIsEmptyError) Error() string

type RepositoryUpToDateError

type RepositoryUpToDateError struct{}

func (*RepositoryUpToDateError) Error

func (e *RepositoryUpToDateError) Error() string

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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