Documentation
¶
Index ¶
- Constants
- Variables
- func IsErrNoUpdates(err error) bool
- type CloneOption
- type FetchOption
- type GitRepo
- func (g *GitRepo) CheckoutBranch(branch string) error
- func (g *GitRepo) CheckoutCommit(hash string) error
- func (g *GitRepo) CheckoutRef(reference string) error
- func (g *GitRepo) Clone(url string, opts ...CloneOption) error
- func (g *GitRepo) Commit(msg string) (plumbing.Hash, error)
- func (g *GitRepo) CreateTag(name, hash, message string) error
- func (g *GitRepo) Exists(path string) (bool, error)
- func (g *GitRepo) Fetch(opts ...FetchOption) error
- func (g *GitRepo) FetchTags() error
- func (g *GitRepo) GetBranchReference(branchName string) (*plumbing.Reference, error)
- func (g *GitRepo) GetCommit(hash plumbing.Hash) (*object.Commit, error)
- func (g *GitRepo) GetCurrentBranch() (string, error)
- func (g *GitRepo) GetCurrentTag() (string, error)
- func (g *GitRepo) GetTagCommit(tagName string) (*object.Commit, error)
- func (g *GitRepo) GitFs() fs.Filesystem
- func (g *GitRepo) HasBranch(name string) (bool, error)
- func (g *GitRepo) HasChanges() (bool, error)
- func (g *GitRepo) Head() (*plumbing.Reference, error)
- func (g *GitRepo) Init() error
- func (g *GitRepo) ListTags(fetch bool) ([]*object.Tag, error)
- func (g *GitRepo) MkdirAll(path string) error
- func (g *GitRepo) NewBranch(name string) error
- func (g *GitRepo) NewTag(commit plumbing.Hash, name, message string) (*plumbing.Reference, error)
- func (g *GitRepo) Open() error
- func (g *GitRepo) Patch(fromHash, toHash plumbing.Hash) (*object.Patch, error)
- func (g *GitRepo) PatchHead(fromHash plumbing.Hash) (*object.Patch, error)
- func (g *GitRepo) PatchToString(patch *object.Patch) string
- func (g *GitRepo) Pull() error
- func (g *GitRepo) Push() error
- func (g *GitRepo) Raw() *gg.Repository
- func (g *GitRepo) ReadDir(path string) ([]os.FileInfo, error)
- func (g *GitRepo) ReadFile(path string) ([]byte, error)
- func (g *GitRepo) RemoveFile(path string) error
- func (g *GitRepo) SetAuth(auth *http.BasicAuth)
- func (g *GitRepo) StageFile(path string) error
- func (g *GitRepo) UnstageFile(path string) error
- func (g *GitRepo) WalkTags(startTag, endTag *object.Tag) iter.Seq2[*object.Commit, error]
- func (g *GitRepo) WorkFs() fs.Filesystem
- func (g *GitRepo) WriteFile(path string, contents []byte) error
- type GitRepoOption
Constants ¶
const ( DEFAULT_AUTHOR = "Catalyst Forge" DEFAULT_EMAIL = "forge@projectcatalyst.io" )
Variables ¶
var (
ErrTagNotFound = fmt.Errorf("tag not found")
)
Functions ¶
func IsErrNoUpdates ¶
IsErrNoUpdates returns true if the error is NoErrAlreadyUpToDate.
Types ¶
type CloneOption ¶
type CloneOption func(*gg.CloneOptions)
CloneOption is an option for cloning a repository.
func WithCloneDepth ¶
func WithCloneDepth(depth int) CloneOption
WithCloneDepth sets the depth of the clone.
type FetchOption ¶
type FetchOption func(*gg.FetchOptions)
FetchOption is an option for fetching a repository.
func WithFetchDepth ¶
func WithFetchDepth(depth int) FetchOption
WithFetchDepth sets the depth of the fetch.
func WithRefSpec ¶
func WithRefSpec(refSpec string) FetchOption
WithRefSpec sets the reference specification for the fetch.
func WithRemoteName ¶
func WithRemoteName(name string) FetchOption
WithRemoteName sets the name of the remote to fetch.
type GitRepo ¶
type GitRepo struct {
// contains filtered or unexported fields
}
GitRepo is a high-level representation of a git repository.
func NewCachedRepo ¶
NewCachedRepo creates a new GitRepo instance that uses a predefined cache path. If the repository does not exist in the cache, it will be cloned. If the repository exists in the cache, it will be opened.
func NewGitRepo ¶
NewGitRepo creates a new GitRepo instance.
func (*GitRepo) CheckoutBranch ¶
CheckoutBranch checks out a branch with the given name.
func (*GitRepo) CheckoutCommit ¶
CheckoutCommit checks out a commit with the given hash.
func (*GitRepo) CheckoutRef ¶
CheckoutRef checks out a reference (commit, branch, or tag) with the given name.
func (*GitRepo) Clone ¶
func (g *GitRepo) Clone(url string, opts ...CloneOption) error
Clone loads a repository from a git remote.
func (*GitRepo) Fetch ¶
func (g *GitRepo) Fetch(opts ...FetchOption) error
Fetch fetches changes from the remote repository.
func (*GitRepo) GetBranchReference ¶
GetBranchReference returns the reference for a given branch name.
func (*GitRepo) GetCurrentBranch ¶
GetCurrentBranch returns the name of the current branch.
func (*GitRepo) GetCurrentTag ¶
GetCurrentTag returns the tag of the current HEAD commit, if it exists.
func (*GitRepo) GetTagCommit ¶
GetTagCommit returns the commit object that the given tag is pointing to.
func (*GitRepo) GitFs ¶
func (g *GitRepo) GitFs() fs.Filesystem
GitFs returns the filesystem for the .git directory.
func (*GitRepo) HasBranch ¶
HasBranch returns true if the repository has a branch with the given name.
func (*GitRepo) HasChanges ¶
HasChanges returns true if the repository has changes.
func (*GitRepo) ListTags ¶
ListTags returns all annotated tags in the repository. If fetch is true, it will fetch tags from the remote repository before listing them. Lightweight tags are ignored and only annotated tag objects are returned.
func (*GitRepo) PatchHead ¶
PatchHead generates a patch between a given commit and the current HEAD.
func (*GitRepo) PatchToString ¶
PatchToString converts a patch to a unified diff string.
func (*GitRepo) Pull ¶
Pull fetches changes from the remote repository and merges them into the current branch.
func (*GitRepo) Raw ¶
func (g *GitRepo) Raw() *gg.Repository
Raw returns the underlying go-git repository.
func (*GitRepo) RemoveFile ¶
RemoveFile removes a file from the repository.
func (*GitRepo) SetAuth ¶
SetAuth sets the authentication for the interacting with a remote repository.
func (*GitRepo) UnstageFile ¶
UnstageFile removes a file from the staging area.
func (*GitRepo) WalkTags ¶
WalkTags walks the commits between two tags. Will return an error if the start tag is not an ancestor of the end tag.
func (*GitRepo) WorkFs ¶
func (g *GitRepo) WorkFs() fs.Filesystem
WorkFs returns the filesystem for the working directory.
type GitRepoOption ¶
type GitRepoOption func(*GitRepo)
func WithAuth ¶
func WithAuth(username, password string) GitRepoOption
WithAuth sets the authentication for the interacting with a remote repository.
func WithAuthor ¶
func WithAuthor(name, email string) GitRepoOption
WithAuthor sets the author for all commits.
func WithFS ¶
func WithFS(fs fs.Filesystem) GitRepoOption
WithFS sets the filesystem for the repository.
func WithGitRemoteInteractor ¶
func WithGitRemoteInteractor(remote remote.GitRemoteInteractor) GitRepoOption
WithGitRemoteInteractor sets the remote interactor for the repository.