git_repo

package
v1.2.61 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const GitReposCacheVersion = "5"
View Source
const GitWorktreesCacheVersion = "9"

Variables

View Source
var ErrLocalRepositoryNotExists = git.ErrRepositoryNotExists

Functions

func GetGitRepoCacheDir

func GetGitRepoCacheDir() string

func GetVirtualMergeParents added in v1.2.57

func GetVirtualMergeParents(ctx context.Context, gitRepo GitRepo, virtualMergeCommit string) (string, string, error)

func GetWorkTreeCacheDir

func GetWorkTreeCacheDir() string

func HasSubmodulesInCommit

func HasSubmodulesInCommit(commit *object.Commit) (bool, error)

func Init added in v1.2.2

func Init(gitDataManager GitDataManager) error

func IsTreeEntryNotFoundInRepoErr added in v1.2.5

func IsTreeEntryNotFoundInRepoErr(err error) bool

Types

type Archive

type Archive interface {
	GetFilePath() string
}

type ArchiveFile

type ArchiveFile struct {
	FilePath string
}

func (*ArchiveFile) GetFilePath

func (a *ArchiveFile) GetFilePath() string

type ArchiveOptions

type ArchiveOptions true_git.ArchiveOptions

type ArchiveType

type ArchiveType string
const (
	FileArchive      ArchiveType = "file"
	DirectoryArchive ArchiveType = "directory"
)

type Base

type Base struct {
	Name string

	Cache Cache
	// contains filtered or unexported fields
}

func NewBase added in v1.2.6

func NewBase(name string, initRepoHandleBackedByWorkTreeFunc func(context.Context, string) (repo_handle.Handle, error)) *Base

func (*Base) CreateArchive added in v1.2.6

func (repo *Base) CreateArchive(ctx context.Context, repoPath, gitDir, repoID, workTreeCacheDir string, opts ArchiveOptions) (archive Archive, err error)

func (*Base) CreateChecksum added in v1.2.6

func (repo *Base) CreateChecksum(ctx context.Context, repoHandle repo_handle.Handle, opts ChecksumOptions) (checksum string, err error)

func (*Base) CreatePatch added in v1.2.6

func (repo *Base) CreatePatch(ctx context.Context, repoPath, gitDir, repoID, workTreeCacheDir string, opts PatchOptions) (patch Patch, err error)

func (*Base) GetCommitTreeEntry added in v1.2.11

func (repo *Base) GetCommitTreeEntry(ctx context.Context, commit string, path string) (*ls_tree.LsTreeEntry, error)

func (*Base) GetName

func (repo *Base) GetName() string

func (*Base) HeadCommitHash added in v1.2.56

func (repo *Base) HeadCommitHash(ctx context.Context) (string, error)

func (*Base) HeadCommitTime added in v1.2.56

func (repo *Base) HeadCommitTime(ctx context.Context) (*time.Time, error)

func (*Base) IsAnyCommitTreeEntriesMatched added in v1.2.12

func (repo *Base) IsAnyCommitTreeEntriesMatched(ctx context.Context, commit string, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error)

func (*Base) IsCommitDirectoryExist added in v1.2.11

func (repo *Base) IsCommitDirectoryExist(ctx context.Context, commit, path string) (exist bool, err error)

IsCommitDirectoryExist resolves symlinks and returns true if the resolved commit tree entry is Dir or Submodule.

func (*Base) IsCommitFileExist added in v1.2.11

func (repo *Base) IsCommitFileExist(ctx context.Context, commit, path string) (exist bool, err error)

IsCommitFileExist resolves symlinks and returns true if the resolved commit tree entry is Regular, Deprecated, or Executable.

func (*Base) IsCommitTreeEntryDirectory added in v1.2.11

func (repo *Base) IsCommitTreeEntryDirectory(ctx context.Context, commit string, relPath string) (isDirectory bool, err error)

func (*Base) IsCommitTreeEntryExist added in v1.2.11

func (repo *Base) IsCommitTreeEntryExist(ctx context.Context, commit string, relPath string) (exist bool, err error)

func (*Base) LatestBranchCommit

func (repo *Base) LatestBranchCommit(ctx context.Context, branch string) (string, error)

func (*Base) ListCommitFilesWithGlob added in v1.2.11

func (repo *Base) ListCommitFilesWithGlob(ctx context.Context, commit string, dir string, glob string) (files []string, err error)

ListCommitFilesWithGlob returns the list of files by the glob, follows symlinks. The result paths are relative to the passed directory, the method does reverse resolving for symlinks.

func (*Base) ReadCommitFile added in v1.2.11

func (repo *Base) ReadCommitFile(ctx context.Context, commit, path string) (data []byte, err error)

ReadCommitFile resolves symlinks and returns commit tree entry content.

func (*Base) ReadCommitTreeEntryContent added in v1.2.11

func (repo *Base) ReadCommitTreeEntryContent(ctx context.Context, commit string, relPath string) ([]byte, error)

func (*Base) ResolveAndCheckCommitFilePath added in v1.2.11

func (repo *Base) ResolveAndCheckCommitFilePath(ctx context.Context, commit, path string, checkSymlinkTargetFunc func(resolvedPath string) error) (resolvedPath string, err error)

ResolveAndCheckCommitFilePath does ResolveCommitFilePath with an additional check for each resolved link target.

func (*Base) ResolveCommitFilePath added in v1.2.11

func (repo *Base) ResolveCommitFilePath(ctx context.Context, commit, path string) (resolvedPath string, err error)

ResolveCommitFilePath follows symbolic links and returns the resolved path if there is a corresponding tree entry in the repo.

func (*Base) String

func (repo *Base) String() string

func (*Base) TagCommit

func (repo *Base) TagCommit(ctx context.Context, branch string) (string, error)

func (*Base) WalkCommitFiles added in v1.2.11

func (repo *Base) WalkCommitFiles(ctx context.Context, commit string, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error

type Cache added in v1.2.6

type Cache struct {
	Patches   map[string]Patch
	Archives  map[string]Archive
	Checksums sync.Map
	// contains filtered or unexported fields
}

type ChecksumOptions

type ChecksumOptions struct {
	LsTreeOptions
	Commit string
}

func (ChecksumOptions) ID added in v1.2.11

func (opts ChecksumOptions) ID() string

type GitDataManager added in v1.2.2

type GitDataManager interface {
	CreateArchiveFile(ctx context.Context, repoID string, opts ArchiveOptions, tmpPath string) (*ArchiveFile, error)
	GetArchiveFile(ctx context.Context, repoID string, opts ArchiveOptions) (*ArchiveFile, error)
	CreatePatchFile(ctx context.Context, repoID string, opts PatchOptions, tmpPath string, desc *true_git.PatchDescriptor) (*PatchFile, error)
	GetPatchFile(ctx context.Context, repoID string, opts PatchOptions) (*PatchFile, error)
	NewTmpFile() (string, error)
	LockGC(ctx context.Context, shared bool) (lockgate.LockHandle, error)

	GetArchivesCacheDir() string
	GetPatchesCacheDir() string
}
var CommonGitDataManager GitDataManager

type GitRepo

type GitRepo interface {
	String() string
	GetName() string
	IsLocal() bool
	GetWorkTreeDir() string
	RemoteOriginUrl(_ context.Context) (string, error)
	IsShallowClone(ctx context.Context) (bool, error)
	FetchOrigin(ctx context.Context) error
	SyncWithOrigin(ctx context.Context) error

	CreateDetachedMergeCommit(ctx context.Context, fromCommit, toCommit string) (string, error)
	GetCommitTreeEntry(ctx context.Context, commit string, path string) (*ls_tree.LsTreeEntry, error)
	GetMergeCommitParents(ctx context.Context, commit string) ([]string, error)
	GetOrCreateArchive(ctx context.Context, opts ArchiveOptions) (Archive, error)
	GetOrCreateChecksum(ctx context.Context, opts ChecksumOptions) (string, error)
	GetOrCreatePatch(ctx context.Context, opts PatchOptions) (Patch, error)
	HeadCommitHash(ctx context.Context) (string, error)
	HeadCommitTime(ctx context.Context) (*time.Time, error)
	IsAncestor(ctx context.Context, ancestorCommit, descendantCommit string) (bool, error)
	IsCommitDirectoryExist(ctx context.Context, commit, path string) (bool, error)
	IsCommitExists(ctx context.Context, commit string) (bool, error)
	IsCommitFileExist(ctx context.Context, commit, path string) (bool, error)
	IsAnyCommitTreeEntriesMatched(ctx context.Context, commit string, pathScope string, pathMatcher path_matcher.PathMatcher, allFiles bool) (bool, error)
	IsCommitTreeEntryDirectory(ctx context.Context, commit string, relPath string) (bool, error)
	IsCommitTreeEntryExist(ctx context.Context, commit string, relPath string) (bool, error)
	IsEmpty(ctx context.Context) (bool, error)
	LatestBranchCommit(ctx context.Context, branch string) (string, error)
	ListCommitFilesWithGlob(ctx context.Context, commit string, dir string, glob string) ([]string, error)
	ReadCommitFile(ctx context.Context, commit, path string) ([]byte, error)
	ReadCommitTreeEntryContent(ctx context.Context, commit string, relPath string) ([]byte, error)
	ResolveAndCheckCommitFilePath(ctx context.Context, commit, path string, checkSymlinkTargetFunc func(resolvedPath string) error) (string, error)
	ResolveCommitFilePath(ctx context.Context, commit, path string) (string, error)
	TagCommit(ctx context.Context, tag string) (string, error)
	WalkCommitFiles(ctx context.Context, commit string, dir string, pathMatcher path_matcher.PathMatcher, fileFunc func(notResolvedPath string) error) error

	StatusPathList(ctx context.Context, pathMatcher path_matcher.PathMatcher) (list []string, err error)
	ValidateStatusResult(ctx context.Context, pathMatcher path_matcher.PathMatcher) error
}

type Local

type Local struct {
	*Base

	WorkTreeDir string
	GitDir      string
	// contains filtered or unexported fields
}

func OpenLocalRepo

func OpenLocalRepo(ctx context.Context, name, workTreeDir string, opts OpenLocalRepoOptions) (l *Local, err error)

func (*Local) CreateDetachedMergeCommit

func (repo *Local) CreateDetachedMergeCommit(ctx context.Context, fromCommit, toCommit string) (string, error)

func (*Local) FetchOrigin added in v1.1.23

func (repo *Local) FetchOrigin(ctx context.Context) error

func (*Local) GetMergeCommitParents

func (repo *Local) GetMergeCommitParents(_ context.Context, commit string) ([]string, error)

func (*Local) GetOrCreateArchive added in v1.2.6

func (repo *Local) GetOrCreateArchive(ctx context.Context, opts ArchiveOptions) (Archive, error)

func (*Local) GetOrCreateChecksum added in v1.2.6

func (repo *Local) GetOrCreateChecksum(ctx context.Context, opts ChecksumOptions) (checksum string, err error)

func (*Local) GetOrCreatePatch added in v1.2.6

func (repo *Local) GetOrCreatePatch(ctx context.Context, opts PatchOptions) (Patch, error)

func (*Local) GetWorkTreeDir added in v1.2.60

func (repo *Local) GetWorkTreeDir() string

func (*Local) HeadCommitHash added in v1.2.56

func (repo *Local) HeadCommitHash(_ context.Context) (string, error)

func (*Local) HeadCommitTime added in v1.2.56

func (repo *Local) HeadCommitTime(ctx context.Context) (*time.Time, error)

func (*Local) IsAncestor

func (repo *Local) IsAncestor(ctx context.Context, ancestorCommit, descendantCommit string) (bool, error)

func (*Local) IsCommitExists

func (repo *Local) IsCommitExists(ctx context.Context, commit string) (bool, error)

func (*Local) IsEmpty

func (repo *Local) IsEmpty(ctx context.Context) (bool, error)

func (*Local) IsLocal added in v1.2.57

func (repo *Local) IsLocal() bool

func (*Local) IsShallowClone

func (repo *Local) IsShallowClone(ctx context.Context) (bool, error)

func (*Local) PlainOpen

func (repo *Local) PlainOpen() (*git.Repository, error)

func (*Local) RemoteBranchesList

func (repo *Local) RemoteBranchesList(_ context.Context) ([]string, error)

func (*Local) RemoteOriginUrl

func (repo *Local) RemoteOriginUrl(_ context.Context) (string, error)

func (*Local) StatusIndexChecksum added in v1.2.10

func (repo *Local) StatusIndexChecksum(ctx context.Context) (string, error)

func (*Local) StatusPathList added in v1.2.8

func (repo *Local) StatusPathList(ctx context.Context, pathMatcher path_matcher.PathMatcher) (list []string, err error)

func (*Local) SyncWithOrigin added in v1.1.23

func (repo *Local) SyncWithOrigin(ctx context.Context) error

func (*Local) TagsList

func (repo *Local) TagsList(_ context.Context) ([]string, error)

func (*Local) ValidateStatusResult added in v1.2.10

func (repo *Local) ValidateStatusResult(ctx context.Context, pathMatcher path_matcher.PathMatcher) error

type LsTreeOptions

type LsTreeOptions ls_tree.LsTreeOptions

type OpenLocalRepoOptions added in v1.1.21

type OpenLocalRepoOptions struct {
	WithServiceHeadCommit bool
	ServiceBranchOptions  ServiceBranchOptions
}

type Patch

type Patch interface {
	GetFilePath() string
	IsEmpty() bool
	HasBinary() bool
	GetPaths() []string
	GetBinaryPaths() []string
}

type PatchFile

type PatchFile struct {
	FilePath   string
	Descriptor *true_git.PatchDescriptor
}

func (*PatchFile) GetBinaryPaths

func (p *PatchFile) GetBinaryPaths() []string

func (*PatchFile) GetFilePath

func (p *PatchFile) GetFilePath() string

func (*PatchFile) GetPaths

func (p *PatchFile) GetPaths() []string

func (*PatchFile) HasBinary

func (p *PatchFile) HasBinary() bool

func (*PatchFile) IsEmpty

func (p *PatchFile) IsEmpty() bool

type PatchOptions

type PatchOptions true_git.PatchOptions

type Remote

type Remote struct {
	*Base
	Url      string
	IsDryRun bool

	Endpoint *transport.Endpoint
}

func OpenRemoteRepo

func OpenRemoteRepo(name, url string) (*Remote, error)

func (*Remote) Clone

func (repo *Remote) Clone(ctx context.Context) (bool, error)

func (*Remote) CloneAndFetch

func (repo *Remote) CloneAndFetch(ctx context.Context) error

func (*Remote) CreateDetachedMergeCommit

func (repo *Remote) CreateDetachedMergeCommit(ctx context.Context, fromCommit, toCommit string) (string, error)

func (*Remote) FetchOrigin added in v1.2.60

func (repo *Remote) FetchOrigin(ctx context.Context) error

func (*Remote) GetClonePath

func (repo *Remote) GetClonePath() string

func (*Remote) GetMergeCommitParents

func (repo *Remote) GetMergeCommitParents(_ context.Context, commit string) ([]string, error)

func (*Remote) GetOrCreateArchive added in v1.2.6

func (repo *Remote) GetOrCreateArchive(ctx context.Context, opts ArchiveOptions) (Archive, error)

func (*Remote) GetOrCreateChecksum added in v1.2.6

func (repo *Remote) GetOrCreateChecksum(ctx context.Context, opts ChecksumOptions) (checksum string, err error)

func (*Remote) GetOrCreatePatch added in v1.2.6

func (repo *Remote) GetOrCreatePatch(ctx context.Context, opts PatchOptions) (Patch, error)

func (*Remote) GetWorkTreeDir added in v1.2.60

func (repo *Remote) GetWorkTreeDir() string

func (*Remote) HeadCommitHash added in v1.2.56

func (repo *Remote) HeadCommitHash(ctx context.Context) (string, error)

func (*Remote) HeadCommitTime added in v1.2.56

func (repo *Remote) HeadCommitTime(ctx context.Context) (*time.Time, error)

func (*Remote) IsAncestor

func (repo *Remote) IsAncestor(ctx context.Context, ancestorCommit, descendantCommit string) (bool, error)

func (*Remote) IsCommitExists

func (repo *Remote) IsCommitExists(ctx context.Context, commit string) (bool, error)

func (*Remote) IsEmpty

func (repo *Remote) IsEmpty(ctx context.Context) (bool, error)

func (*Remote) IsLocal added in v1.2.57

func (repo *Remote) IsLocal() bool

func (*Remote) IsShallowClone added in v1.2.60

func (repo *Remote) IsShallowClone(ctx context.Context) (bool, error)

func (*Remote) LatestBranchCommit

func (repo *Remote) LatestBranchCommit(ctx context.Context, branch string) (string, error)

func (*Remote) RemoteBranchesList

func (repo *Remote) RemoteBranchesList(_ context.Context) ([]string, error)

func (*Remote) RemoteOriginUrl

func (repo *Remote) RemoteOriginUrl(_ context.Context) (string, error)

func (*Remote) StatusPathList added in v1.2.60

func (repo *Remote) StatusPathList(ctx context.Context, pathMatcher path_matcher.PathMatcher) ([]string, error)

func (*Remote) SyncWithOrigin added in v1.2.60

func (repo *Remote) SyncWithOrigin(ctx context.Context) error

func (*Remote) TagCommit

func (repo *Remote) TagCommit(ctx context.Context, tag string) (string, error)

func (*Remote) TagsList

func (repo *Remote) TagsList(_ context.Context) ([]string, error)

func (*Remote) ValidateEndpoint

func (repo *Remote) ValidateEndpoint() error

func (*Remote) ValidateStatusResult added in v1.2.60

func (repo *Remote) ValidateStatusResult(ctx context.Context, pathMatcher path_matcher.PathMatcher) error

type ServiceBranchOptions added in v1.2.13

type ServiceBranchOptions struct {
	Prefix          string
	GlobExcludeList []string
}

type StatusFilesFoundError added in v1.2.10

type StatusFilesFoundError struct {
	PathList []string
	// contains filtered or unexported fields
}

type SubmoduleAddedAndNotCommittedError added in v1.2.8

type SubmoduleAddedAndNotCommittedError SubmoduleErrorBase

type SubmoduleCommitChangedError added in v1.2.8

type SubmoduleCommitChangedError SubmoduleErrorBase

type SubmoduleDeletedError added in v1.2.8

type SubmoduleDeletedError SubmoduleErrorBase

type SubmoduleErrorBase added in v1.2.8

type SubmoduleErrorBase struct {
	SubmodulePath string
	// contains filtered or unexported fields
}

type SubmoduleHasUncommittedChangesError added in v1.2.8

type SubmoduleHasUncommittedChangesError SubmoduleErrorBase

type SubmoduleHasUntrackedChangesError added in v1.2.8

type SubmoduleHasUntrackedChangesError SubmoduleErrorBase

type UncommittedFilesFoundError added in v1.2.10

type UncommittedFilesFoundError StatusFilesFoundError

type UntrackedFilesFoundError added in v1.2.10

type UntrackedFilesFoundError StatusFilesFoundError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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