gogit

package module
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 31 Imported by: 8

Documentation

Index

Constants

View Source
const ClientName = "go-git"

ClientName is the string representation of Client.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*repository.DiscardCloser
	// contains filtered or unexported fields
}

Client implements repository.Client.

func NewClient

func NewClient(path string, authOpts *git.AuthOptions, clientOpts ...ClientOption) (*Client, error)

NewClient returns a new GoGitClient.

func (*Client) Clone

func (g *Client) Clone(ctx context.Context, url string, cfg repository.CloneConfig) (*git.Commit, error)

func (*Client) Commit

func (g *Client) Commit(info git.Commit, commitOpts ...repository.CommitOption) (string, error)

func (*Client) Head

func (g *Client) Head() (string, error)

func (*Client) Init

func (g *Client) Init(ctx context.Context, url, branch string) error

func (*Client) IsClean

func (g *Client) IsClean() (bool, error)

func (*Client) Path

func (g *Client) Path() string

func (*Client) Push

func (g *Client) Push(ctx context.Context, cfg repository.PushConfig) error

func (*Client) SwitchBranch

func (g *Client) SwitchBranch(ctx context.Context, branchName string) error

SwitchBranch switches the current branch to the given branch name.

No new references are fetched from the remote during the process, this is to ensure that the same flow can be used across all Git servers, regardless of them requiring MULTI_ACK or not. Once MULTI_ACK is implemented in go-git, this can be revisited.

If more than one remote branch state is required, create the gogit client using WithSingleBranch(false). This will fetch all remote branches as part of the initial clone. Note that this is fully compatible with shallow clones.

The following cases are handled: - Branch does not exist results in one being created using HEAD of the worktree. - Branch exists only remotely, results in a local branch being created tracking the remote HEAD. - Branch exists only locally, results in a checkout to the existing branch. - Branch exists locally and remotely, the local branch will take precendece.

To override a remote branch with the state from the current branch, (i.e. image automation controller), use WithForcePush(true) in combination with WithSingleBranch(true). This will ignore the remote branch's existence.

type ClientOption

type ClientOption func(*Client) error

func WithDiskStorage

func WithDiskStorage() ClientOption

WithDiskStorage configures the client to store the worktree and all Git related objects on disk.

func WithFallbackToDefaultKnownHosts added in v0.3.0

func WithFallbackToDefaultKnownHosts() ClientOption

WithFallbackToDefaultKnownHosts enables falling back to the default known_hosts of the machine if the provided auth options don't provide it.

func WithInsecureCredentialsOverHTTP added in v0.2.0

func WithInsecureCredentialsOverHTTP() ClientOption

WithInsecureCredentialsOverHTTP enables credentials being used over HTTP. This is not recommended for production environments.

func WithMemoryStorage

func WithMemoryStorage() ClientOption

WithMemoryStorage configures the client to store the worktree and all Git related objects in memory.

func WithProxy added in v0.11.2

func WithProxy(opts transport.ProxyOptions) ClientOption

WithProxy configures the proxy settings to be used for all remote operations.

func WithSingleBranch added in v0.4.0

func WithSingleBranch(singleBranch bool) ClientOption

WithSingleBranch indicates whether only the references of a single branch will be fetched during cloning operations. For read-only clones, and for single branch write operations, a single branch is advised for performance reasons.

For write operations that require multiple branches, for example, cloning from main and pushing into a feature branch, this should be disabled. Otherwise a second fetch will be required to get the state of the target branch, which won't work against some Git servers due to MULTI_ACK not being implemented in go-git.

By default this is enabled.

func WithStorer

func WithStorer(s storage.Storer) ClientOption

WithStorer configures the client to use the provided Storer for storing all Git related objects.

func WithWorkTreeFS

func WithWorkTreeFS(wt billy.Filesystem) ClientOption

WithWorkTreeFS configures the client to use the provided filesystem for storing the worktree.

type CustomPublicKeys

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

CustomPublicKeys is a wrapper around ssh.PublicKeys to help us customize the ssh config. It implements ssh.AuthMethod.

func (*CustomPublicKeys) ClientConfig

func (a *CustomPublicKeys) ClientConfig() (*gossh.ClientConfig, error)

func (*CustomPublicKeys) Name

func (a *CustomPublicKeys) Name() string

func (*CustomPublicKeys) String

func (a *CustomPublicKeys) String() string

type DefaultAuth added in v0.3.0

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

func (*DefaultAuth) ClientConfig added in v0.3.0

func (a *DefaultAuth) ClientConfig() (*gossh.ClientConfig, error)

func (*DefaultAuth) Name added in v0.3.0

func (a *DefaultAuth) Name() string

func (*DefaultAuth) String added in v0.3.0

func (a *DefaultAuth) String() string

Jump to

Keyboard shortcuts

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