Documentation
¶
Index ¶
Constants ¶
const ( // DefaultSSHPort 22 DefaultSSHPort = 22 // DefaultHTTPPort 80 DefaultHTTPPort = 80 )
Variables ¶
var DefaultHosts = [...]Host{ *NewHost("github.com"), *NewHost("gitlab.com"), *NewHost("bitbucket.org"), *NewHost("coding.net", "git.coding.net"), *NewHost("git.oschina.net"), }
DefaultHosts include common public git hosts TODO: maybe use an string array to construct this is better
Functions ¶
func GetAllHostsMap ¶
GetAllHostsMap return a map with host name(url) as key
func GetCloneDirectory ¶
GetCloneDirectory return path for clone destination
func GetRepoBasePath ¶
func GetRepoBasePath() string
GetRepoBasePath return path in ordr of : config, GOPATH, current directory
Types ¶
type Host ¶
type Host struct {
URL string
SupportHTTPS bool
SupportSSH bool
HTTPPort int
SSHPort int
SSHURL string
}
Host represent a remote git host server like github.com, gitlab.com
func NewHost ¶
NewHost return a new Host object with default config https://golang.org/doc/effective_go.html#allocation_new TODO: why use poniter instead of return object directly, The Go Programming Language P32 2.3.2 pointer
type Remote ¶
type Remote struct {
// Name is origin, upstream etc
Name string
// Protocol is http, https, ssh
Protocol string
// Host is the git host provider domain name, like github.com
// TODO: store a HostURL and embed a Host object
Host string
// Port is used for remote that does not use default ssh port
Port int
// Owner is user name or organization name
Owner string
// Repo is repository name
Repo string
// SupportHTTPS shows if the host is using HTTPS
// TODO: change is to a method
SupportHTTPS bool
// SSH clone url can ignore config for known hosts
IgnoreConfig bool
}
Remote represents a remote git repository
func NewFromURL ¶
NewFromURL returns a remote based on the url, which could be - url in browser https://github.com/dyweb/Ayi - import url, like import "github.com/dyweb/Ayi/util" - short url dyweb/Ayi, default host would be github, but it can also use GitLab based on your config
type Repo ¶
Repo is a repository with local path and remote
func CloneFromURL ¶
CloneFromURL will clone a repository based on short url or normal git clone url