sharedrepo

package
v1.0.1-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupMergeConflicts

func CleanupMergeConflicts(conflicts []string) []string

func Run

func Run(
	ctx context.Context,
	refUpdater *hook.RefUpdater,
	tmpDir, repoPath string,
	fn func(s *SharedRepo) error,
	alternates ...string,
) error

Run is helper function used to run the provided function inside a shared repository. If the provided hook.RefUpdater is not nil it will be used to update the reference. Inside the provided inline function there should be a call to initialize the ref updater. If the provided hook.RefUpdater is nil the entire operation is a read-only.

Types

type SharedRepo

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

func NewSharedRepo

func NewSharedRepo(
	baseTmpDir string,
	sourceRepoPath string,
) (*SharedRepo, error)

NewSharedRepo creates a new temporary bare repository.

func (*SharedRepo) AddObjectToIndex

func (r *SharedRepo) AddObjectToIndex(
	ctx context.Context,
	mode string,
	objectHash sha.SHA,
	objectPath string,
) error

AddObjectToIndex adds the provided object hash to the index with the provided mode and path.

func (*SharedRepo) ClearIndex

func (r *SharedRepo) ClearIndex(ctx context.Context) error

ClearIndex clears the git index.

func (*SharedRepo) Close

func (r *SharedRepo) Close(ctx context.Context)

func (*SharedRepo) CommitSHAsForRebase

func (r *SharedRepo) CommitSHAsForRebase(
	ctx context.Context,
	target, source sha.SHA,
) ([]sha.SHA, error)

CommitSHAsForRebase returns list of SHAs of the commits between the two git revisions for a rebase operation - in the order they should be rebased in.

func (*SharedRepo) CommitTree

func (r *SharedRepo) CommitTree(
	ctx context.Context,
	author, committer *api.Signature,
	treeHash sha.SHA,
	message string,
	signoff bool,
	parentCommits ...sha.SHA,
) (sha.SHA, error)

CommitTree creates a commit from a given tree for the user with provided message.

func (*SharedRepo) CreateFile

func (r *SharedRepo) CreateFile(
	ctx context.Context,
	treeishSHA sha.SHA,
	filePath, mode string,
	payload []byte,
) error

func (*SharedRepo) DeleteFile

func (r *SharedRepo) DeleteFile(ctx context.Context, filePath string) error

func (*SharedRepo) Directory

func (r *SharedRepo) Directory() string

func (*SharedRepo) GetTreeSHA

func (r *SharedRepo) GetTreeSHA(
	ctx context.Context,
	rev string,
) (sha.SHA, error)

GetTreeSHA returns the tree SHA of the rev.

func (*SharedRepo) Init

func (r *SharedRepo) Init(ctx context.Context, alternates ...string) error

func (*SharedRepo) LsFiles

func (r *SharedRepo) LsFiles(
	ctx context.Context,
	filenames ...string,
) ([]string, error)

LsFiles checks if the given filename arguments are in the index.

func (*SharedRepo) MergeBase

func (r *SharedRepo) MergeBase(
	ctx context.Context,
	rev1, rev2 string,
) (string, error)

MergeBase returns number of commits between the two git revisions.

func (*SharedRepo) MergeTree

func (r *SharedRepo) MergeTree(
	ctx context.Context,
	commitMergeBase, commitTarget, commitSource sha.SHA,
) (sha.SHA, []string, error)

MergeTree merges commits in git index.

func (*SharedRepo) MoveFile

func (r *SharedRepo) MoveFile(
	ctx context.Context,
	treeishSHA sha.SHA,
	filePath string,
	objectSHA sha.SHA,
	mode string,
	payload []byte,
) (string, error)

func (*SharedRepo) MoveObjects

func (r *SharedRepo) MoveObjects(ctx context.Context) error

MoveObjects moves git object from the shared repository to the original repository.

func (*SharedRepo) PatchTextFile

func (r *SharedRepo) PatchTextFile(
	ctx context.Context,
	treeishSHA sha.SHA,
	filePath string,
	objectSHA sha.SHA,
	payloadsRaw [][]byte,
) error

func (*SharedRepo) RemoveFilesFromIndex

func (r *SharedRepo) RemoveFilesFromIndex(
	ctx context.Context,
	filenames ...string,
) error

RemoveFilesFromIndex removes the given files from the index.

func (*SharedRepo) SetDefaultIndex

func (r *SharedRepo) SetDefaultIndex(ctx context.Context) error

SetDefaultIndex sets the git index to our HEAD.

func (*SharedRepo) SetIndex

func (r *SharedRepo) SetIndex(ctx context.Context, treeish sha.SHA) error

SetIndex sets the git index to the provided treeish.

func (*SharedRepo) ShowFile

func (r *SharedRepo) ShowFile(
	ctx context.Context,
	filePath string,
	rev string,
	writer io.Writer,
) error

ShowFile dumps show file and write to io.Writer.

func (*SharedRepo) UpdateFile

func (r *SharedRepo) UpdateFile(
	ctx context.Context,
	treeishSHA sha.SHA,
	filePath string,
	objectSHA sha.SHA,
	mode string,
	payload []byte,
) error

func (*SharedRepo) WriteGitObject

func (r *SharedRepo) WriteGitObject(
	ctx context.Context,
	content io.Reader,
) (sha.SHA, error)

WriteGitObject writes the provided content to the object db and returns its hash.

func (*SharedRepo) WriteTree

func (r *SharedRepo) WriteTree(ctx context.Context) (sha.SHA, error)

WriteTree writes the current index as a tree to the object db and returns its hash.

Jump to

Keyboard shortcuts

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