Documentation
¶
Index ¶
- Variables
- type Client
- type Git
- func (g *Git) Add(path string) error
- func (g *Git) Checkout(branch string, create, force bool) error
- func (g *Git) Clean() (bool, string, error)
- func (g *Git) Clone(url string, progress io.Writer) (err error)
- func (g *Git) Commit(msg string) (string, string, error)
- func (g *Git) CreateBranch(name string) error
- func (g *Git) DiffCommits(commitAHash, commitBHash string, files ...string) (bool, string, error)
- func (g *Git) NewFile(name string, body []byte) error
- func (g *Git) OpenFile(path string) (io.ReadCloser, error)
- func (g *Git) PullMaster() error
- func (g *Git) Push(branches ...string) error
- func (g *Git) ReadDir(path string) ([]os.FileInfo, error)
- func (g *Git) ReadFile(path string) ([]byte, error)
- func (g *Git) RemoveBranch(name string) error
- func (g *Git) RemoveRemoteBranch(name string) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDirtyBranch is returned if the branch is dirty. ErrDirtyBranch = errors.New("dirty branch") // ErrInvalidBranch is returned if the branch does not exist. ErrInvalidBranch = errors.New("invalid branch") )
var ErrUninitializedAuth = errors.New("uninitialized auth")
ErrUninitializedAuth is returned if the auth object was not set.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// NewFile creates a new file in git workspace.
NewFile(name string, body []byte) error
// ReadFile reads a file from a git workspace.
ReadFile(path string) ([]byte, error)
// Clone the repository from url.
Clone(url string, progress io.Writer) (err error)
// CreateBranch creates a local branch.
CreateBranch(name string) error
// DiffCommits compares 2 commits and returns the difference.
DiffCommits(commitAHash, commitBHash string, files ...string) (bool, string, error)
// Checkout to a git branch
Checkout(branch string, create, force bool) error
// RemoveBranch removes a local branch.
RemoveBranch(name string) error
// RemoveRemoteBranch removes a remote branch.
RemoveRemoteBranch(name string) error
// PullMaster pulls and checks out to master branch.
PullMaster() error
// ReadDir reads the files/dirs in git workspace.
ReadDir(path string) ([]os.FileInfo, error)
// OpenFile opens a file from a git workspace.
OpenFile(path string) (io.ReadCloser, error)
// Add works like "git add" to add files to a commit.
Add(path string) error
// Commit makes a new commit.
Commit(msg string) (string, string, error)
// Push branches to remote repo.
Push(branches ...string) error
// Clean returns true if the workspace is clean, similar to "git status"
Clean() (bool, string, error)
}
Client is an interface which describes a git client.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git represents an abstraction over git.
func (*Git) CreateBranch ¶
CreateBranch creates a new git branch.
func (*Git) DiffCommits ¶
DiffCommits commits check the difference between 2 commits. Optionally files can be passed to this function and it will check if the difference was found between commits for specified files. similar to "git diff commitA commitB foo/bar.txt" The function returns 3 values: commitAreTheSame bool, patch string, err error
func (*Git) OpenFile ¶
func (g *Git) OpenFile(path string) (io.ReadCloser, error)
OpenFile opens a new file from git workspace. The caller is responsible for closing it.
func (*Git) PullMaster ¶
PullMaster pulls the latest changes from master branch.
func (*Git) RemoveBranch ¶
RemoveBranch removes a git branch.
func (*Git) RemoveRemoteBranch ¶
RemoveRemoteBranch removes the branch from remote git repo.
type Option ¶
Option is a functional parameter.
func WithGitUserEmail ¶
WithGitUserEmail configures user and email for git commits.
func WithIgnoreKnownHosts ¶
WithIgnoreKnownHosts is a functional option used to disable ssh known hosts option.
func WithRSAKey ¶
WithRSAKey is a option to configure git client with RSA key.