git

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

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

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

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

func ForceProtocol

func ForceProtocol(url, protocol string) string

func GetAllGithubReleases

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

GetAllGithubReleases fetches all releases from a GitHub repository

Types

type CloneOption

type CloneOption func(*CloneOptions)

CloneOption is a function that modifies CloneOptions

func WithBranch

func WithBranch(branch string) CloneOption

WithBranch sets the branch for CloneOptions

func WithCommit

func WithCommit(commit string) CloneOption

WithCommit sets the commit for CloneOptions

func WithLocalPath

func WithLocalPath(localPath string) CloneOption

WithLocalPath sets the local path for CloneOptions

func WithRepoURL

func WithRepoURL(repoURL string) CloneOption

WithRepoURL sets the repo URL for CloneOptions

func WithTag

func WithTag(tag string) CloneOption

WithTag sets the tag for CloneOptions

func WithWriter

func WithWriter(writer io.Writer) CloneOption

WithWriter sets the writer for CloneOptions

type CloneOptions

type CloneOptions struct {
	RepoURL   string
	Commit    string
	Tag       string
	Branch    string
	LocalPath string
	Writer    io.Writer
}

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

func NewCloneOptions

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

func (*CloneOptions) Clone

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

Clone clones a git repository

func (*CloneOptions) ForceGitUrl

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

func (cloneOpts *CloneOptions) Validate() error

Validate checks if the CloneOptions are valid

type GitHubRelease

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