git

package
v0.57.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGitHubOrGitLabURL

func IsGitHubOrGitLabURL(u string) bool

IsGitHubOrGitLabURL checks if the url is a github or gitlab url.

func IsGitHubShortURL

func IsGitHubShortURL(s string) bool

IsGitHubShortURL returns true for github-friendly short urls such as srl-labs/containerlab.

func IsGitHubURL

func IsGitHubURL(url *neturl.URL) bool

IsGitHubURL checks if the url is a github url.

func IsGitLabURL

func IsGitLabURL(u *neturl.URL) bool

IsGitLabURL returns true if the given url is a gitlab url.

Types

type Git

type Git interface {
	// Clone takes the given GitRepo reference and clones the repo
	// with its internal implementation.
	Clone() error
}

type GitHubRepo

type GitHubRepo struct {
	GitRepoStruct
}

GitHubRepo struct holds the parsed github url.

func NewGitHubRepoFromURL

func NewGitHubRepoFromURL(url *neturl.URL) (*GitHubRepo, error)

NewGitHubRepoFromURL parses the given url and returns a GitHubRepo.

type GitLabRepo

type GitLabRepo struct {
	GitRepoStruct
}

GitLabRepo represents a gitlab repository.

func NewGitLabRepoFromURL

func NewGitLabRepoFromURL(url *neturl.URL) (*GitLabRepo, error)

NewGitLabRepoFromURL parses the given url and returns a GitLabRepo.

type GitRepo

type GitRepo interface {
	GetName() string
	GetFilename() string
	GetPath() []string
	GetCloneURL() *url.URL
	GetBranch() string
}

func NewRepo

func NewRepo(urlPath string) (GitRepo, error)

NewRepo parses the given git urlPath and returns an interface that is backed by Github or Gitlab repo implementations.

type GitRepoStruct

type GitRepoStruct struct {
	// original URL parsed from the user input
	URL *url.URL
	// CloneURL is the URL that will be used for cloning the repo
	CloneURL       *url.URL
	ProjectOwner   string
	RepositoryName string
	// GitBranch is the referenced Git branch name.
	GitBranch string
	// Path is the path within the repository where the file is located.
	Path []string
	// FileName is the name of the file located at repo_root/path/filename.
	FileName string
}

GitRepoStruct is a struct that contains all the fields required for a GitRepo instance.

func (*GitRepoStruct) GetBranch

func (u *GitRepoStruct) GetBranch() string

GetBranch returns the referenced Git branch name. the empty string is returned otherwise.

func (*GitRepoStruct) GetCloneURL

func (u *GitRepoStruct) GetCloneURL() *url.URL

GetCloneURL returns the CloneURL of the repository.

func (*GitRepoStruct) GetFilename

func (u *GitRepoStruct) GetFilename() string

GetFilename returns the filename if a file was specifically referenced. the empty string is returned otherwise.

func (*GitRepoStruct) GetName

func (u *GitRepoStruct) GetName() string

GetName returns the repository name.

func (*GitRepoStruct) GetPath

func (u *GitRepoStruct) GetPath() []string

GetPath returns the path of the repository.

type GoGit

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

func NewGoGit

func NewGoGit(gitRepo GitRepo) *GoGit

func (*GoGit) Clone

func (g *GoGit) Clone() error

Clone takes the given GitRepo reference and clones the repo with its internal implementation.

Jump to

Keyboard shortcuts

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