git

package
v0.2.68 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddFilesCommand

type AddFilesCommand struct {
	Files []string
}

AddFilesCommand is a command that adds files to the git index.

type CheckoutBranchCommand

type CheckoutBranchCommand struct {
	Branch string
}

CheckoutBranchCommand is a command that checks out a branch in the git repository.

type CommitChangesCommand

type CommitChangesCommand struct {
	Message     string
	AuthorName  string
	AuthorEmail string
}

CommitChangesCommand is a command that commits changes to the git repository.

type CreateBranchCommand

type CreateBranchCommand struct {
	Branch string
}

CreateBranchCommand is a command that creates a new branch in the git repository.

type GitCommand

type GitCommand interface {
	// contains filtered or unexported methods
}

GitCommand is an interface that defines a method to execute a command on a git repository.

type GitContext

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

GitContext is a struct that contains the context for a git repository.

func InitNewRepository

func InitNewRepository(repoName string) (*GitContext, error)

InitNewRepository initializes a new local GitContext with the given repository name.

func NewRepository

func NewRepository(repoURL string) *GitContext

NewRepository creates a new GitContext with the given repository URL and authentication method.

func (*GitContext) CheckIfRepoExists added in v0.2.68

func (ctx *GitContext) CheckIfRepoExists() (bool, error)

func (*GitContext) Cleanup

func (ctx *GitContext) Cleanup() error

Cleanup removes the temporary directory of the GitContext. This should be called after the GitContext is no longer needed. Use defer ctx.Cleanup() after creating a GitContext.

func (*GitContext) ExecuteCommand

func (ctx *GitContext) ExecuteCommand(cmd GitCommand) error

ExecuteCommand executes the given GitCommand on the GitContext.

func (*GitContext) ExecuteCommandChain

func (ctx *GitContext) ExecuteCommandChain(cmds []GitCommand) error

ExecuteCommandChain executes the given chain of GitCommands on the GitContext. If any of the commands fail, the chain is stopped and the error is returned. Otherwise, nil is returned. The commands are executed in the order they are given. When command fails the chain is stopped, but previously executed commands are not reverted.

func (*GitContext) GetHash

func (ctx *GitContext) GetHash() (string, error)

func (*GitContext) GetReferenceName

func (ctx *GitContext) GetReferenceName() (string, error)

func (*GitContext) GetTargetReferenceName

func (ctx *GitContext) GetTargetReferenceName() (string, error)

func (*GitContext) WithBasicAuth

func (ctx *GitContext) WithBasicAuth(username, password string) *GitContext

WithBasicAuth sets the username and password for the GitContext.

func (*GitContext) WithCABundle

func (ctx *GitContext) WithCABundle(caBundle []byte) *GitContext

WithCABundle sets the CA bytes for the GitContext. CA will be used as the certificate of trust for the TLS connection.

func (*GitContext) WithInsecureSkipTLS

func (ctx *GitContext) WithInsecureSkipTLS(insecureSkipTLS bool) *GitContext

WithInsecureSkipTLS sets the insecure skip TLS flag for the GitContext. Default is false. If true, check of the certificate is skipped, not recommended in production.

func (*GitContext) WithProxy

func (ctx *GitContext) WithProxy(proxyURL, proxyUsername, proxyPassword string) *GitContext

WithProxy sets the proxy URL, username, and password for the GitContext.

func (*GitContext) WithReferenceName

func (ctx *GitContext) WithReferenceName(referenceName string) *GitContext

WithReferenceName sets the reference name for the GitContext.

func (*GitContext) WithRemote added in v0.2.68

func (ctx *GitContext) WithRemote(remote RemoteInterface) *GitContext

func (*GitContext) WithRemoteName

func (ctx *GitContext) WithRemoteName(remoteName string) *GitContext

WithRemoteName sets the remote name for the GitContext. Default is "origin".

func (*GitContext) WithSingleBranch

func (ctx *GitContext) WithSingleBranch(singleBranch bool) *GitContext

WithSingleBranch sets the single branch flag for the GitContext. Default is false. If true, only the WithReferenceName set branch is cloned.

func (*GitContext) WithTempDir

func (ctx *GitContext) WithTempDir(tempDir string) *GitContext

WithTempDir sets the temporary directory for the GitContext. Default is the OS temporary directory.

func (*GitContext) WithToken

func (ctx *GitContext) WithToken(token string) *GitContext

WithToken sets the token for the GitContext.

type GitHash

type GitHash plumbing.Hash

type GitInterface added in v0.2.67

type GitInterface interface {
	ExecuteCommand(cmd GitCommand) error
	ExecuteCommandChain(cmds []GitCommand) error
	GetHash() (string, error)
	GetReferenceName() (string, error)
	GetTargetReferenceName() (string, error)
	Cleanup() error
	CheckIfRepoExists() (bool, error)
}

type MergeBranchCommand

type MergeBranchCommand struct {
	SourceBranch string
	TargetBranch string
}

MergeBranchCommand is a command that merges a branch into another branch in the git repository.

type PullChangesCommand

type PullChangesCommand struct {
	Remote string
	Branch string
}

PullChangesCommand is a command that pulls changes from a remote git repository.

type PushChangesCommand

type PushChangesCommand struct {
	Remote string
	Branch string
}

PushChangesCommand is a command that pushes changes to a remote git repository.

type ReadFileCommand

type ReadFileCommand struct {
	FilePath string
	Content  []byte
}

ReadFileCommand is a command that reads a file from a git repository.

type RemoteInterface added in v0.2.68

type RemoteInterface interface {
	List(o *git.ListOptions) ([]*plumbing.Reference, error)
}

type RemoveFileCommand

type RemoveFileCommand struct {
	FilePath string
}

RemoveFileCommand is a command that removes a file from a git repository.

type WriteFileCommand

type WriteFileCommand struct {
	FilePath string
	Content  []byte
}

WriteFileCommand is a command that writes a file to a git repository.

Jump to

Keyboard shortcuts

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