Documentation
¶
Index ¶
- Constants
- func GetSSHKey(filePath string, localfs afero.Fs) (*ssh.PublicKeys, error)
- type CloneOption
- type Repo
- func (r *Repo) AddToFS(fs afero.Fs, gitFile *object.File, fullPath string) error
- func (r *Repo) Checkout(branch plumbing.ReferenceName) error
- func (r *Repo) CheckoutCommit(hash plumbing.Hash) error
- func (r *Repo) Clone(uri string, targetPath string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
- func (r *Repo) Commit(commitMsg string, opts *git.CommitOptions) (plumbing.Hash, error)
- func (r *Repo) CreateBranch(branchName string) error
- func (r *Repo) CreateRemote(name string, urls []string) (*git.Remote, error)
- func (r *Repo) DirectoryExists(relPath string) (bool, error)
- func (r *Repo) FileExists(relPath string) (bool, error)
- func (r *Repo) GetAuth() transport.AuthMethod
- func (r *Repo) GetFile(relPath string) (*object.File, error)
- func (r *Repo) GetRepo() *git.Repository
- func (r *Repo) GetTree() *git.Worktree
- func (r *Repo) Open(repoType RepoType, location string, branch string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
- func (r *Repo) OpenInMemory(location string, branch string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
- func (r *Repo) OpenLocal(location string, branch string) (*git.Repository, *git.Worktree, error)
- func (r *Repo) Push(opts *git.PushOptions) error
- func (r *Repo) Remote(name string) (*git.Remote, error)
- func (r *Repo) SetBasicAuth(username, password string)
- func (r *Repo) SetKey(key *ssh.PublicKeys)
- func (r *Repo) SetRepo(repo *git.Repository)
- func (r *Repo) SetSource(source int)
- func (r *Repo) SetTree(tree *git.Worktree)
- func (r *Repo) SourceIs(source int) bool
- func (r *Repo) WalkTree(fn func(*object.File) error) error
- type RepoLike
- type RepoOpt
- type RepoType
Constants ¶
const ( SourceUnknown = iota SourceMemory SourceLocal )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CloneOption ¶
type CloneOption func(*git.CloneOptions)
CloneOption represents a function that configures clone options.
func WithNoTags ¶
func WithNoTags() CloneOption
WithNoTags configures the clone to skip fetching tags.
func WithRecurseSubmodules ¶
func WithRecurseSubmodules() CloneOption
WithRecurseSubmodules configures recursive submodule cloning.
func WithShallowClone ¶
func WithShallowClone(depth int) CloneOption
WithShallowClone configures a shallow clone with the specified depth.
func WithSingleBranch ¶
func WithSingleBranch(branch string) CloneOption
WithSingleBranch configures the clone to only fetch a single branch.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) CheckoutCommit ¶
CheckoutCommit checks out a specific commit by hash.
func (*Repo) Clone ¶
func (r *Repo) Clone(uri string, targetPath string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
Clone clones a git repository to a target path on the filesystem Supports both remote URLs and local git repository paths with clone options.
func (*Repo) CreateBranch ¶
CreateBranch creates a branch in the git tree.
func (*Repo) CreateRemote ¶
func (*Repo) DirectoryExists ¶
DirectoryExists checks if a directory exists in the git repository at the given relative path In git, directories don't exist as separate entities - we check if any files exist under the path.
func (*Repo) FileExists ¶
FileExists checks if a file exists in the git repository at the given relative path.
func (*Repo) GetAuth ¶
func (r *Repo) GetAuth() transport.AuthMethod
func (*Repo) GetRepo ¶
func (r *Repo) GetRepo() *git.Repository
func (*Repo) Open ¶
func (r *Repo) Open(repoType RepoType, location string, branch string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
Open opens a local git repository. if no repo exists will init a repo.
func (*Repo) OpenInMemory ¶
func (r *Repo) OpenInMemory(location string, branch string, opts ...CloneOption) (*git.Repository, *git.Worktree, error)
func (*Repo) SetBasicAuth ¶
func (*Repo) SetKey ¶
func (r *Repo) SetKey(key *ssh.PublicKeys)
func (*Repo) SetRepo ¶
func (r *Repo) SetRepo(repo *git.Repository)
type RepoLike ¶
type RepoLike interface {
SourceIs(int) bool
SetSource(int)
SetRepo(*git.Repository)
GetRepo() *git.Repository
SetKey(*ssh.PublicKeys)
SetBasicAuth(string, string)
GetAuth() transport.AuthMethod
SetTree(*git.Worktree)
GetTree() *git.Worktree
Checkout(plumbing.ReferenceName) error
CheckoutCommit(plumbing.Hash) error
CreateBranch(string) error
Push(*git.PushOptions) error
Commit(string, *git.CommitOptions) (plumbing.Hash, error)
OpenInMemory(string, string, ...CloneOption) (*git.Repository, *git.Worktree, error)
OpenLocal(string, string) (*git.Repository, *git.Worktree, error)
Open(RepoType, string, string, ...CloneOption) (*git.Repository, *git.Worktree, error)
Clone(string, string, ...CloneOption) (*git.Repository, *git.Worktree, error)
// Git tree operations for in-memory repositories
WalkTree(func(*object.File) error) error
FileExists(string) (bool, error)
DirectoryExists(string) (bool, error)
GetFile(string) (*object.File, error)
AddToFS(fs afero.Fs, gitFile *object.File, fullPath string) error
}