Documentation
¶
Overview ¶
Package vcsurl parses VCS repository URLs in many common formats.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RepoInfo ¶
type RepoInfo struct {
CloneURL string // clone URL
VCS VCS // VCS type
RepoHost RepoHost // repo hosting site
Username string // username of repo owner on repo hosting site
Name string // base name of repo on repo hosting site
FullName string // full name of repo on repo hosting site
Rev string // a specific revision (commit ID, branch, etc.)
}
RepoInfo describes a VCS repository.
func Parse ¶
Parses a string that resembles a VCS repository URL. See TestParse for a list of supported URL formats.
Example ¶
urls := []string{
"github.com/alice/libfoo",
"git://github.com/bob/libbar",
"code.google.com/p/libqux",
"https://code.google.com/p/libbaz",
}
for i, url := range urls {
if info, err := vcsurl.Parse(url); err == nil {
fmt.Printf("%d. %s %s\n", i+1, info.VCS, info.CloneURL)
fmt.Printf(" name: %s\n", info.Name)
fmt.Printf(" host: %s\n", info.RepoHost)
} else {
fmt.Printf("error parsing %s\n")
}
}
Output: 1. git git://github.com/alice/libfoo.git name: libfoo host: github.com 2. git git://github.com/bob/libbar.git name: libbar host: github.com 3. hg https://code.google.com/p/libqux name: libqux host: code.google.com 4. hg https://code.google.com/p/libbaz name: libbaz host: code.google.com
Click to show internal directories.
Click to hide internal directories.
