git

package
v0.0.0-...-2e56a1b Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-3-Clause Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clone

type Clone struct {
	Config         *RepositoryConfig
	StorageType    StorageType
	StorageOptions interface{} // Either GitDiskStorageOption or GitRAMStorageOption type
	Repository     *gogit.Repository
	FileSystem     billy.Filesystem
}

Clone is a struct for local git repository cloned

func NewGitCloneToDisk

func NewGitCloneToDisk(repoConfig *RepositoryConfig, storageOptions *DiskStorageOption) (*Clone, error)

NewGitCloneToDisk creates a clone of a git repository using local disk

func NewGitCloneToRAM

func NewGitCloneToRAM(repoConfig *RepositoryConfig, storageOptions *RAMStorageOption) (*Clone, error)

NewGitCloneToRAM creates a clone of a git repository using RAM

func (*Clone) GetFileSystem

func (clone *Clone) GetFileSystem() billy.Filesystem

GetFileSystem returns filesystem to access the git repository

func (*Clone) Release

func (clone *Clone) Release()

Release deletes local git repository and releases all resources

type DiskStorageOption

type DiskStorageOption struct {
	// ClonePath is a file path to clone
	ClonePath string
}

DiskStorageOption contains options for DiskStorageType

type MemStore

type MemStore struct {
	memory.ConfigStorage
	ObjectStorage
	memory.ShallowStorage
	memory.IndexStorage
	memory.ReferenceStorage
	memory.ModuleStorage
	// contains filtered or unexported fields
}

MemStore augment the original memory storage implementation to set a size limit

type ObjectStorage

type ObjectStorage struct {

	// the original implementation
	memory.ObjectStorage
	// contains filtered or unexported fields
}

ObjectStorage implements github.com/go-git/go-git/v5/plumbing/storer.EncodedObjectStorer

func (*ObjectStorage) SetEncodedObject

func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error)

SetEncodedObject override the SetEncodedObject implementation from memory.ObjectStorage

type RAMStorageOption

type RAMStorageOption struct {
	// SizeLimit is a size limit for data in Bytes, 0 for unlimited
	SizeLimit int64
}

RAMStorageOption contains options for RAMStorageType

type ReferenceType

type ReferenceType string

ReferenceType is a type for reference type of git

const (
	// BranchReferenceType is for Branch reference type
	BranchReferenceType ReferenceType = "branch"
	// TagReferenceType is for Tag reference type
	TagReferenceType ReferenceType = "tag"
)

type RepositoryConfig

type RepositoryConfig struct {
	URL           string
	Username      string // optional
	Password      string // optional
	SSHPrivateKey []byte // optional
	ReferenceType ReferenceType
	ReferenceName string
}

RepositoryConfig is a configuration struct

func NewGitRepositoryConfigWithAccessTokenAuth

func NewGitRepositoryConfigWithAccessTokenAuth(url string, accessToken string, referenceType ReferenceType, referenceName string) *RepositoryConfig

NewGitRepositoryConfigWithAccessTokenAuth creates a git repository config with access token auth

func NewGitRepositoryConfigWithNoAuth

func NewGitRepositoryConfigWithNoAuth(url string, referenceType ReferenceType, referenceName string) *RepositoryConfig

NewGitRepositoryConfigWithNoAuth creates a git repository config with no auth

func NewGitRepositoryConfigWithPasswordAuth

func NewGitRepositoryConfigWithPasswordAuth(url string, username string, password string, referenceType ReferenceType, referenceName string) *RepositoryConfig

NewGitRepositoryConfigWithPasswordAuth creates a git repository config with password auth

func NewGitRepositoryConfigWithSSHAuth

func NewGitRepositoryConfigWithSSHAuth(url string, sshUsername string, privateKey []byte, passwordForPrivateKey string, referenceType ReferenceType, referenceName string) *RepositoryConfig

NewGitRepositoryConfigWithSSHAuth creates a git repository config with ssh auth sshUsername is usually "git", passwordForPrivateKey is oftem empty

type SizeLimit

type SizeLimit struct {
	Limit     int64
	TotalSize int64
}

SizeLimit is a struct that stores size limit and current size of data

func (SizeLimit) ExceeedLimit

func (c SizeLimit) ExceeedLimit() bool

ExceeedLimit checks whether limit has been exceeded

func (*SizeLimit) IncrementSize

func (c *SizeLimit) IncrementSize(delta int64)

IncrementSize increment the size counter atmoically

type StorageType

type StorageType string

StorageType is a type for git local storage

const (
	// DiskStorageType is a disk storage
	DiskStorageType StorageType = "disk"
	// RAMStorageType is a RAM storage
	RAMStorageType StorageType = "ram"
)

Jump to

Keyboard shortcuts

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