forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodehost.go
More file actions
39 lines (30 loc) · 1011 Bytes
/
Copy pathcodehost.go
File metadata and controls
39 lines (30 loc) · 1011 Bytes
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
package github
import (
"net/url"
"github.com/sourcegraph/sourcegraph/pkg/api"
"github.com/sourcegraph/sourcegraph/pkg/extsvc"
)
// ServiceType is the (api.ExternalRepoSpec).ServiceType value for GitHub repositories. The ServiceID value
// is the base URL to the GitHub instance (https://github.com or the GitHub Enterprise URL).
const ServiceType = "github"
// ExternalRepoSpec returns an api.ExternalRepoSpec that refers to the specified GitHub repository.
func ExternalRepoSpec(repo *Repository, baseURL url.URL) *api.ExternalRepoSpec {
return &api.ExternalRepoSpec{
ID: repo.ID,
ServiceType: ServiceType,
ServiceID: extsvc.NormalizeBaseURL(&baseURL).String(),
}
}
type CodeHost struct {
id string
}
var _ extsvc.CodeHost = ((*CodeHost)(nil))
func NewCodeHost(baseURL *url.URL) *CodeHost {
return &CodeHost{id: extsvc.NormalizeBaseURL(baseURL).String()}
}
func (h *CodeHost) ServiceID() string {
return h.id
}
func (h *CodeHost) ServiceType() string {
return ServiceType
}