Documentation
¶
Index ¶
- Constants
- Variables
- func CreateBareGitRepo(path string) (err error)
- func IsGitRepoExists(repoPath string) (ok bool)
- type Client
- type GitAuthType
- type GitCheckoutOption
- type GitClient
- func (c *GitClient) Add(filePath string) (err error)
- func (c *GitClient) Checkout(opts ...GitCheckoutOption) (err error)
- func (c *GitClient) CheckoutBranch(branch string, opts ...GitCheckoutOption) (err error)
- func (c *GitClient) CheckoutBranchFromRef(branch string, ref *plumbing.Reference, opts ...GitCheckoutOption) (err error)
- func (c *GitClient) CheckoutBranchWithRemote(branch, remote string, ref *plumbing.Reference, opts ...GitCheckoutOption) (err error)
- func (c *GitClient) CheckoutBranchWithRemoteFromRef(branch, remote string, ref *plumbing.Reference, opts ...GitCheckoutOption) (err error)
- func (c *GitClient) CheckoutHash(hash string, opts ...GitCheckoutOption) (err error)
- func (c *GitClient) Commit(msg string, opts ...GitCommitOption) (err error)
- func (c *GitClient) CommitAll(msg string, opts ...GitCommitOption) (err error)
- func (c *GitClient) CreateBranch(branch, remote string, ref *plumbing.Reference) (err error)
- func (c *GitClient) CreateRemote(cfg *config.RemoteConfig) (r *git.Remote, err error)
- func (c *GitClient) DeleteRemote(name string) (err error)
- func (c *GitClient) Dispose() (err error)
- func (c *GitClient) GetAuthType() (authType GitAuthType)
- func (c *GitClient) GetBranches() (branches []GitRef, err error)
- func (c *GitClient) GetCurrentBranch() (branch string, err error)
- func (c *GitClient) GetCurrentBranchRef() (ref *GitRef, err error)
- func (c *GitClient) GetIsMem() (isMem bool)
- func (c *GitClient) GetLogs() (logs []GitLog, err error)
- func (c *GitClient) GetLogsWithRefs() (logs []GitLog, err error)
- func (c *GitClient) GetPassword() (password string)
- func (c *GitClient) GetPath() (path string)
- func (c *GitClient) GetPrivateKey() (key string)
- func (c *GitClient) GetPrivateKeyPath() (path string)
- func (c *GitClient) GetRemote(name string) (r *git.Remote, err error)
- func (c *GitClient) GetRemoteRefs(remoteName string) (gitRefs []GitRef, err error)
- func (c *GitClient) GetRemoteUrl() (path string)
- func (c *GitClient) GetRepository() (r *git.Repository)
- func (c *GitClient) GetStatus() (statusList []GitFileStatus, err error)
- func (c *GitClient) GetTags() (tags []GitRef, err error)
- func (c *GitClient) GetUsername() (username string)
- func (c *GitClient) Init() (err error)
- func (c *GitClient) IsRemoteChanged() (ok bool, err error)
- func (c *GitClient) MoveBranch(from, to string) (err error)
- func (c *GitClient) Pull(opts ...GitPullOption) (err error)
- func (c *GitClient) Push(opts ...GitPushOption) (err error)
- func (c *GitClient) Reset(opts ...GitResetOption) (err error)
- func (c *GitClient) SetAuthType(authType GitAuthType)
- func (c *GitClient) SetIsMem(isMem bool)
- func (c *GitClient) SetPassword(password string)
- func (c *GitClient) SetPath(path string)
- func (c *GitClient) SetPrivateKey(key string)
- func (c *GitClient) SetPrivateKeyPath(path string)
- func (c *GitClient) SetRemoteUrl(url string)
- func (c *GitClient) SetUsername(username string)
- type GitCloneOption
- func WithAuthClone(auth transport.AuthMethod) GitCloneOption
- func WithDepthClone(depth int) GitCloneOption
- func WithNoCheckout(noCheckout bool) GitCloneOption
- func WithRecurseSubmodules(recurseSubmodules git.SubmoduleRescursivity) GitCloneOption
- func WithRemoteName(name string) GitCloneOption
- func WithSingleBranch(singleBranch bool) GitCloneOption
- func WithTags(tags git.TagMode) GitCloneOption
- func WithURL(url string) GitCloneOption
- type GitCommitOption
- type GitFileStatus
- type GitInitType
- type GitLog
- type GitOption
- func WithAuthType(authType GitAuthType) GitOption
- func WithDefaultBranch(branch string) GitOption
- func WithIsMem() GitOption
- func WithPassword(password string) GitOption
- func WithPath(path string) GitOption
- func WithPrivateKey(key string) GitOption
- func WithPrivateKeyPath(path string) GitOption
- func WithRemoteUrl(url string) GitOption
- func WithUsername(username string) GitOption
- type GitOptions
- type GitPullOption
- func WithAuthPull(auth transport.AuthMethod) GitPullOption
- func WithBranchNamePull(branch string) GitPullOption
- func WithDepthPull(depth int) GitPullOption
- func WithForcePull(force bool) GitPullOption
- func WithRecurseSubmodulesPull(recurseSubmodules git.SubmoduleRescursivity) GitPullOption
- func WithRemoteNamePull(name string) GitPullOption
- type GitPushOption
- type GitRef
- type GitResetOption
Constants ¶
View Source
const ( GitRemoteNameOrigin = "origin" GitRemoteNameUpstream = "upstream" GitRemoteNameCrawlab = "crawlab" )
View Source
const ( GitBranchNameMaster = "master" GitBranchNameMain = "main" GitBranchNameRelease = "release" GitBranchNameTest = "test" GitBranchNameDevelop = "develop" )
View Source
const ( GitRefTypeBranch = "branch" GitRefTypeTag = "tag" )
View Source
const GitDefaultBranchName = GitBranchNameMaster
View Source
const GitDefaultRemoteName = GitRemoteNameOrigin
Variables ¶
View Source
var ( ErrInvalidArgsLength = errors.New("invalid arguments length") ErrUnsupportedType = errors.New("unsupported type") ErrInvalidAuthType = errors.New("invalid auth type") ErrInvalidOptions = errors.New("invalid options") ErrRepoAlreadyExists = errors.New("repo already exists") ErrInvalidRepoPath = errors.New("invalid repo path") ErrUnableToGetCurrentBranch = errors.New("unable to get current branch") ErrUnableToCloneWithEmptyRemoteUrl = errors.New("unable to clone with empty remote url") ErrInvalidHeadRef = errors.New("invalid head ref") ErrNoMatchedRemoteBranch = errors.New("no matched remote branch") )
View Source
var GitMemFileSystem = sync.Map{}
View Source
var GitMemStorages = sync.Map{}
Functions ¶
func CreateBareGitRepo ¶
func IsGitRepoExists ¶
Types ¶
type Client ¶
type Client interface { Init() (err error) Dispose() (err error) Clone(opts ...GitCloneOption) (err error) Checkout(opts ...GitCheckoutOption) (err error) Commit(msg string, opts ...GitCommitOption) (err error) Pull(opts ...GitPullOption) (err error) Push(opts ...GitPushOption) (err error) Reset(opts ...GitResetOption) (err error) }
type GitAuthType ¶
type GitAuthType int
const ( GitAuthTypeNone GitAuthType = iota GitAuthTypeHTTP GitAuthTypeSSH )
type GitCheckoutOption ¶
type GitCheckoutOption func(o *git.CheckoutOptions)
func WithBranch ¶
func WithBranch(branch string) GitCheckoutOption
func WithHash ¶
func WithHash(hash string) GitCheckoutOption
type GitClient ¶
type GitClient struct {
// contains filtered or unexported fields
}
func CloneGitRepo ¶
func CloneGitRepo(path, url string, opts ...GitCloneOption) (c *GitClient, err error)
func NewGitClient ¶
func (*GitClient) Checkout ¶
func (c *GitClient) Checkout(opts ...GitCheckoutOption) (err error)
func (*GitClient) CheckoutBranch ¶
func (c *GitClient) CheckoutBranch(branch string, opts ...GitCheckoutOption) (err error)
func (*GitClient) CheckoutBranchFromRef ¶ added in v0.6.1
func (*GitClient) CheckoutBranchWithRemote ¶ added in v0.6.1
func (*GitClient) CheckoutBranchWithRemoteFromRef ¶ added in v0.6.1
func (*GitClient) CheckoutHash ¶
func (c *GitClient) CheckoutHash(hash string, opts ...GitCheckoutOption) (err error)
func (*GitClient) Commit ¶
func (c *GitClient) Commit(msg string, opts ...GitCommitOption) (err error)
func (*GitClient) CommitAll ¶
func (c *GitClient) CommitAll(msg string, opts ...GitCommitOption) (err error)
func (*GitClient) CreateBranch ¶ added in v0.6.1
func (*GitClient) CreateRemote ¶ added in v0.6.1
func (c *GitClient) CreateRemote(cfg *config.RemoteConfig) (r *git.Remote, err error)
func (*GitClient) DeleteRemote ¶ added in v0.6.1
func (*GitClient) GetAuthType ¶
func (c *GitClient) GetAuthType() (authType GitAuthType)
func (*GitClient) GetBranches ¶ added in v0.6.1
func (*GitClient) GetCurrentBranch ¶
func (*GitClient) GetCurrentBranchRef ¶ added in v0.6.1
func (*GitClient) GetLogsWithRefs ¶ added in v0.6.1
func (*GitClient) GetPassword ¶ added in v0.6.1
func (*GitClient) GetPrivateKey ¶ added in v0.6.1
func (*GitClient) GetPrivateKeyPath ¶
func (*GitClient) GetRemoteRefs ¶ added in v0.6.1
func (*GitClient) GetRemoteUrl ¶
func (*GitClient) GetRepository ¶
func (c *GitClient) GetRepository() (r *git.Repository)
func (*GitClient) GetStatus ¶ added in v0.6.1
func (c *GitClient) GetStatus() (statusList []GitFileStatus, err error)
func (*GitClient) GetUsername ¶
func (*GitClient) IsRemoteChanged ¶ added in v0.6.1
func (*GitClient) MoveBranch ¶ added in v0.6.1
func (*GitClient) Pull ¶
func (c *GitClient) Pull(opts ...GitPullOption) (err error)
func (*GitClient) Push ¶
func (c *GitClient) Push(opts ...GitPushOption) (err error)
func (*GitClient) Reset ¶
func (c *GitClient) Reset(opts ...GitResetOption) (err error)
func (*GitClient) SetAuthType ¶ added in v0.6.1
func (c *GitClient) SetAuthType(authType GitAuthType)
func (*GitClient) SetPassword ¶ added in v0.6.1
func (*GitClient) SetPrivateKey ¶ added in v0.6.1
func (*GitClient) SetPrivateKeyPath ¶ added in v0.6.1
func (*GitClient) SetRemoteUrl ¶ added in v0.6.1
func (*GitClient) SetUsername ¶ added in v0.6.1
type GitCloneOption ¶
type GitCloneOption func(o *git.CloneOptions)
func WithAuthClone ¶
func WithAuthClone(auth transport.AuthMethod) GitCloneOption
func WithDepthClone ¶
func WithDepthClone(depth int) GitCloneOption
func WithNoCheckout ¶
func WithNoCheckout(noCheckout bool) GitCloneOption
func WithRecurseSubmodules ¶
func WithRecurseSubmodules(recurseSubmodules git.SubmoduleRescursivity) GitCloneOption
func WithRemoteName ¶
func WithRemoteName(name string) GitCloneOption
func WithSingleBranch ¶
func WithSingleBranch(singleBranch bool) GitCloneOption
func WithTags ¶
func WithTags(tags git.TagMode) GitCloneOption
func WithURL ¶
func WithURL(url string) GitCloneOption
type GitCommitOption ¶
type GitCommitOption func(o *git.CommitOptions)
func WithAll ¶
func WithAll(all bool) GitCommitOption
func WithAuthor ¶
func WithAuthor(author *object.Signature) GitCommitOption
func WithCommitter ¶
func WithCommitter(committer *object.Signature) GitCommitOption
func WithParents ¶
func WithParents(parents []plumbing.Hash) GitCommitOption
func WithSignKey ¶
func WithSignKey(signKey *openpgp.Entity) GitCommitOption
type GitFileStatus ¶ added in v0.6.1
type GitOption ¶
type GitOption func(c *GitClient)
func WithAuthType ¶
func WithAuthType(authType GitAuthType) GitOption
func WithDefaultBranch ¶ added in v0.6.1
func WithPassword ¶
func WithPrivateKey ¶
func WithPrivateKeyPath ¶
func WithRemoteUrl ¶
func WithUsername ¶
type GitOptions ¶
type GitOptions struct {
// contains filtered or unexported fields
}
type GitPullOption ¶
type GitPullOption func(o *git.PullOptions)
func WithAuthPull ¶
func WithAuthPull(auth transport.AuthMethod) GitPullOption
func WithBranchNamePull ¶ added in v0.6.1
func WithBranchNamePull(branch string) GitPullOption
func WithDepthPull ¶
func WithDepthPull(depth int) GitPullOption
func WithForcePull ¶
func WithForcePull(force bool) GitPullOption
func WithRecurseSubmodulesPull ¶
func WithRecurseSubmodulesPull(recurseSubmodules git.SubmoduleRescursivity) GitPullOption
func WithRemoteNamePull ¶
func WithRemoteNamePull(name string) GitPullOption
type GitPushOption ¶
type GitPushOption func(o *git.PushOptions)
func WithAuthPush ¶
func WithAuthPush(auth transport.AuthMethod) GitPushOption
func WithForcePush ¶
func WithForcePush(force bool) GitPushOption
func WithPrune ¶
func WithPrune(prune bool) GitPushOption
func WithRefSpecs ¶
func WithRefSpecs(specs []config.RefSpec) GitPushOption
func WithRemoteNamePush ¶
func WithRemoteNamePush(name string) GitPushOption
type GitResetOption ¶
type GitResetOption func(o *git.ResetOptions)
func WithCommit ¶
func WithCommit(commit plumbing.Hash) GitResetOption
func WithMode ¶
func WithMode(mode git.ResetMode) GitResetOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.