utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitClone

func GitClone(url string, target string) error

func IsRoot

func IsRoot(filepath string) bool

func IsURL

func IsURL(u string) bool

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func ParseURL

func ParseURL(rawURL string) (u *url.URL, err error)

ParseURL normalizes git remote urls.

func ReadJson

func ReadJson(filepath string, v interface{}) error

func RenderString

func RenderString(templateString string, funcMap template.FuncMap) (string, error)

func RepoInfoFromURL

func RepoInfoFromURL(u *url.URL) (host string, owner string, name string, err error)

Extract GitHub repository information from a git remote URL.

func ResolvePath

func ResolvePath(filepath string) (string, error)

Types

type GitClient

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

func NewGitClient

func NewGitClient(repo string) *GitClient

func (*GitClient) Config

func (gc *GitClient) Config(name string) (string, error)

func (*GitClient) GetCurrentVersion

func (gc *GitClient) GetCurrentVersion() string

getCurrentVersion determines the current version for non-local git extensions.

func (*GitClient) GetLatestVersion

func (gc *GitClient) GetLatestVersion() (string, error)

func (*GitClient) GetOrigin

func (gc *GitClient) GetOrigin() string

func (*GitClient) Pull

func (gc *GitClient) Pull() error

type Repository

type Repository struct {
	Host  string
	Owner string
	Name  string
}

func ParseWithHost

func ParseWithHost(s, host string) (repo Repository, err error)

Parse extracts the repository information from the following string formats: "OWNER/REPO", "HOST/OWNER/REPO", and a full URL. If the format does not specify a host, use the host provided.

func (Repository) FullName

func (r Repository) FullName() string

func (Repository) Url

func (r Repository) Url() string

type RestClient

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

func NewGHClient

func NewGHClient(host string) RestClient

func (RestClient) Do

func (c RestClient) Do(method string, path string, body io.Reader, response interface{}) error

func (RestClient) DoWithContext

func (c RestClient) DoWithContext(ctx context.Context, method string, path string, body io.Reader, response interface{}) error

func (RestClient) Get

func (c RestClient) Get(path string, resp interface{}) error

Jump to

Keyboard shortcuts

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