git

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneRepo

func CloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) (bool, error)

CloneRepo will clone the repository at the given URL into the given path. If a repository is already initialized at the given path, it will not be cloned again.

The bool returned states whether the repository was cloned or not.

func LogHostKeyCallback

func LogHostKeyCallback(logger func(string, ...any)) gossh.HostKeyCallback

LogHostKeyCallback is a HostKeyCallback that just logs host keys and does nothing else.

func ProgressWriter

func ProgressWriter(write func(line string, args ...any)) io.WriteCloser

func ReadPrivateKey

func ReadPrivateKey(path string) (gossh.Signer, error)

ReadPrivateKey attempts to read an SSH private key from path and returns an ssh.Signer.

func SetupRepoAuth

func SetupRepoAuth(logf func(string, ...any), options *options.Options) transport.AuthMethod

SetupRepoAuth determines the desired AuthMethod based on options.GitURL:

| Git URL format | GIT_USERNAME | GIT_PASSWORD | Auth Method | | ------------------------|--------------|--------------|-------------| | https?://host.tld/repo | Not Set | Not Set | None | | https?://host.tld/repo | Not Set | Set | HTTP Basic | | https?://host.tld/repo | Set | Not Set | HTTP Basic | | https?://host.tld/repo | Set | Set | HTTP Basic | | file://path/to/repo | - | - | None | | path/to/repo | - | - | None | | All other formats | - | - | SSH |

For SSH authentication, the default username is "git" but will honour GIT_USERNAME if set.

If SSH_PRIVATE_KEY_PATH is set, an SSH private key will be read from that path and the SSH auth method will be configured with that key.

If SSH_KNOWN_HOSTS is not set, the SSH auth method will be configured to accept and log all host keys. Otherwise, host key checking will be performed as usual.

func ShallowCloneRepo

func ShallowCloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) error

ShallowCloneRepo will clone the repository at the given URL into the given path with a depth of 1. If the destination folder exists and is not empty, the clone will not be performed.

The bool returned states whether the repository was cloned or not.

Types

type CloneRepoOptions

type CloneRepoOptions struct {
	Path    string
	Storage billy.Filesystem

	RepoURL      string
	RepoAuth     transport.AuthMethod
	Progress     sideband.Progress
	Insecure     bool
	SingleBranch bool
	Depth        int
	CABundle     []byte
	ProxyOptions transport.ProxyOptions
}

func CloneOptionsFromOptions

func CloneOptionsFromOptions(logf func(string, ...any), options options.Options) (CloneRepoOptions, error)

Jump to

Keyboard shortcuts

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