-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrepo.go
53 lines (44 loc) · 1.64 KB
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package gps
import (
"github.com/shurcooL/vcsstate"
"golang.org/x/tools/go/vcs"
)
// Repo represents the state of a single repository.
type Repo struct {
// Root is the import path corresponding to the root of the repository.
Root string
// At most one of VCS or RemoteVCS should be not nil.
// If both are nil, then Local and Remote structs are expected to be already populated.
// TODO: Consider if it'd be better to split this into two distinct structs.
// VCS allows getting the state of the VCS.
VCS vcsstate.VCS
// Path is the local filesystem path to the repository.
// It must be set if VCS is not nil.
Path string
// Cmd can be used to update this local repository inside a GOPATH workspace.
// It must be set if VCS is not nil.
Cmd *vcs.Cmd
// RemoteVCS allows getting the remote state of the VCS.
RemoteVCS vcsstate.RemoteVCS
// RemoteURL is the remote URL, including scheme.
// It must be set if RemoteVCS is not nil.
RemoteURL string
Local struct {
// RemoteURL is the remote URL, including scheme.
RemoteURL string
Revision string // Revision of the default branch (not necessarily the checked out one).
}
Remote struct {
// RepoURL is the repository URL, including scheme, as determined dynamically from the import path.
RepoURL string
Branch string // Default branch, as determined from remote. Only populated if VCS or RemoteVCS is non-nil.
Revision string // Revision of the default branch.
}
}
// ImportPathPattern returns an import path pattern that matches all of the Go packages in this repo.
// E.g.:
//
// "github.com/owner/repo/..."
func (r Repo) ImportPathPattern() string {
return r.Root + "/..."
}