git

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Overview

This file mainly provides some functions that can be used to adapt for git downloading by go-getter.

Index

Constants

View Source
const GIT_PROTOCOL = "git::"

Variables

This section is empty.

Functions

func Clone

func Clone(repoURL string, tagName string, localPath string, writer io.Writer) (*git.Repository, error)

Clone will clone from `repoURL` to `localPath` via git by tag name. Deprecated: This function will be removed in a future version. Use CloneWithOpts instead.

func CloneWithOpts added in v0.6.0

func CloneWithOpts(opts ...CloneOption) (*git.Repository, error)

CloneWithOpts will clone from `repoURL` to `localPath` via git by using CloneOptions

func Fetch added in v0.11.0

func Fetch(dir string, args ...string) error

Fetch fetches the latest changes from a remote repository

func ForceProtocol added in v0.8.1

func ForceProtocol(url, protocol string) string

func GetAllGithubReleases added in v0.8.7

func GetAllGithubReleases(url string) ([]string, error)

GetAllGithubReleases fetches all releases from a GitHub repository

func IsGitBareRepo added in v0.11.0

func IsGitBareRepo(dir string) bool

IsGitBareRepo checks if a directory is a bare git repository

Types

type CloneOption added in v0.6.0

type CloneOption func(*CloneOptions)

CloneOption is a function that modifies CloneOptions

func WithBare added in v0.9.4

func WithBare(isBare bool) CloneOption

WithBare sets the bare flag for CloneOptions

func WithBranch added in v0.6.0

func WithBranch(branch string) CloneOption

WithBranch sets the branch for CloneOptions

func WithCommit added in v0.6.0

func WithCommit(commit string) CloneOption

WithCommit sets the commit for CloneOptions

func WithLocalPath added in v0.6.0

func WithLocalPath(localPath string) CloneOption

WithLocalPath sets the local path for CloneOptions

func WithRepoURL added in v0.6.0

func WithRepoURL(repoURL string) CloneOption

WithRepoURL sets the repo URL for CloneOptions

func WithTag added in v0.6.0

func WithTag(tag string) CloneOption

WithTag sets the tag for CloneOptions

func WithWriter added in v0.6.0

func WithWriter(writer io.Writer) CloneOption

WithWriter sets the writer for CloneOptions

type CloneOptions added in v0.6.0

type CloneOptions struct {
	RepoURL   string
	Commit    string
	Tag       string
	Branch    string
	LocalPath string
	Writer    io.Writer
	Bare      bool // New field to indicate if the clone should be bare
}

CloneOptions is a struct for specifying options for cloning a git repository

func NewCloneOptions added in v0.8.0

func NewCloneOptions(repoUrl, commit, tag, branch, localpath string, Writer io.Writer) *CloneOptions

func (*CloneOptions) CheckoutFromBare added in v0.9.4

func (cloneOpts *CloneOptions) CheckoutFromBare() error

CheckoutFromBare checks out the specified reference from a bare repository

func (*CloneOptions) Clone added in v0.6.0

func (cloneOpts *CloneOptions) Clone() (*git.Repository, error)

Clone clones a git repository, handling both bare and non-bare options

func (*CloneOptions) ForceGitUrl added in v0.8.1

func (cloneOpts *CloneOptions) ForceGitUrl() (string, error)

ForceGitUrl will add the branch, tag or commit to the git URL and force it to the git protocol `<URL>` will return `Git::<URL>?ref=<branch|tag|commit>`

func (*CloneOptions) Validate added in v0.6.0

func (cloneOpts *CloneOptions) Validate() error

Validate checks if the CloneOptions are valid

type GitHubRelease added in v0.8.7

type GitHubRelease struct {
	TagName string `json:"tag_name"`
}

Jump to

Keyboard shortcuts

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