glrepo

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FullNameFromURL

func FullNameFromURL(remoteURL string) (string, error)

FullName returns the the repo with its namespace (like profclems/glab). Respects group and subgroups names

func IsSame

func IsSame(a, b Interface) bool

IsSame compares two GitLab repositories

func RemoteURL

func RemoteURL(project *gitlab.Project, protocol string) string

RemoteURL returns correct git clone URL of a repo based on the user's git_protocol preference

Types

type Interface

type Interface interface {
	RepoName() string
	RepoOwner() string
	RepoNamespace() string
	RepoGroup() string
	RepoHost() string
	FullName() string
	Project(*gitlab.Client) (*gitlab.Project, error)
}

Interface describes an object that represents a GitLab repository Contains methods for these methods representing these placeholders for a project path with :host/:group/:namespace/:repo RepoHost = :host, RepoOwner = :group/:namespace, RepoNamespace = :namespace, FullName = :group/:namespace/:repo, RepoGroup = :group, RepoName = :repo

func FromFullName

func FromFullName(nwo string) (Interface, error)

FromFullName extracts the GitLab repository information from the following formats: "OWNER/REPO", "HOST/OWNER/REPO", "HOST/GROUP/NAMESPACE/REPO", and a full URL.

func FromURL

func FromURL(u *url.URL) (Interface, error)

FromURL extracts the GitLab repository information from a git remote URL

func New

func New(owner, repo string) Interface

New instantiates a GitLab repository from owner and repo name arguments

func NewWithGroup

func NewWithGroup(group, namespace, repo, hostname string) Interface

NewWithGroup instantiates a GitLab repository from group, namespace and repo name arguments

func NewWithHost

func NewWithHost(owner, repo, hostname string) Interface

NewWithHost is like New with an explicit host name

type Project

type Project struct {
	*gitlab.Project
	// contains filtered or unexported fields
}

type Remote

type Remote struct {
	*git.Remote
	Repo Interface
}

Remote represents a git remote mapped to a GitLab repository

func (Remote) FullName

func (r Remote) FullName() string

func (Remote) Project

func (r Remote) Project(client *gitlab.Client) (*gitlab.Project, error)

func (Remote) RepoGroup

func (r Remote) RepoGroup() string

func (Remote) RepoHost

func (r Remote) RepoHost() string

RepoHost is the GitLab hostname that the remote points to

func (Remote) RepoName

func (r Remote) RepoName() string

RepoName is the name of the GitLab repository

func (Remote) RepoNamespace

func (r Remote) RepoNamespace() string

func (Remote) RepoOwner

func (r Remote) RepoOwner() string

RepoOwner is the name of the GitLab account that owns the repo

type Remotes

type Remotes []*Remote

Remotes represents a set of git remotes

func TranslateRemotes

func TranslateRemotes(gitRemotes git.RemoteSet, urlTranslate func(*url.URL) *url.URL) (remotes Remotes)

TODO: accept an interface instead of git.RemoteSet

func (Remotes) FindByName

func (r Remotes) FindByName(names ...string) (*Remote, error)

FindByName returns the first Remote whose name matches the list

func (Remotes) FindByRepo

func (r Remotes) FindByRepo(owner, name string) (*Remote, error)

FindByRepo returns the first Remote that points to a specific GitLab repository

func (Remotes) Len

func (r Remotes) Len() int

https://golang.org/pkg/sort/#Interface

func (Remotes) Less

func (r Remotes) Less(i, j int) bool

func (Remotes) Swap

func (r Remotes) Swap(i, j int)

type ResolvedRemotes

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

func ResolveRemotesToRepos

func ResolveRemotesToRepos(remotes Remotes, client *gitlab.Client, base string) (*ResolvedRemotes, error)

func (*ResolvedRemotes) BaseRepo

func (r *ResolvedRemotes) BaseRepo(interactive bool) (Interface, error)

func (*ResolvedRemotes) HeadRepo

func (r *ResolvedRemotes) HeadRepo(interactive bool) (Interface, error)

func (*ResolvedRemotes) RemoteForRepo

func (r *ResolvedRemotes) RemoteForRepo(repo Interface) (*Remote, error)

RemoteForRepo finds the git remote that points to a repository

Jump to

Keyboard shortcuts

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