forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 86
/
repo.go
95 lines (77 loc) · 2.66 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package fake
import (
"context"
"strings"
"github.com/jenkins-x/go-scm/scm"
)
type repositoryService struct {
client *wrapper
data *Data
}
func (s *repositoryService) FindCombinedStatus(ctx context.Context, repo, ref string) (*scm.CombinedStatus, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) FindUserPermission(ctx context.Context, repo string, user string) (string, *scm.Response, error) {
f := s.data
m := f.UserPermissions[repo]
perm := ""
if m != nil {
perm = m[user]
}
return perm, nil, nil
}
// NormLogin normalizes login strings
var NormLogin = strings.ToLower
func (s *repositoryService) IsCollaborator(ctx context.Context, repo, login string) (bool, *scm.Response, error) {
f := s.data
normed := NormLogin(login)
for _, collab := range f.Collaborators {
if NormLogin(collab) == normed {
return true, nil, nil
}
}
return false, nil, nil
}
func (s *repositoryService) ListCollaborators(ctx context.Context, repo string) ([]scm.User, *scm.Response, error) {
f := s.data
result := make([]scm.User, 0, len(f.Collaborators))
for _, login := range f.Collaborators {
result = append(result, scm.User{Login: login})
}
return result, nil, nil
}
func (s *repositoryService) Find(context.Context, string) (*scm.Repository, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) FindHook(context.Context, string, string) (*scm.Hook, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) FindPerms(context.Context, string) (*scm.Perm, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) List(context.Context, scm.ListOptions) ([]*scm.Repository, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) ListLabels(context.Context, string, scm.ListOptions) ([]*scm.Label, *scm.Response, error) {
f := s.data
la := []*scm.Label{}
for _, l := range f.RepoLabelsExisting {
la = append(la, &scm.Label{Name: l})
}
return la, nil, nil
}
func (s *repositoryService) ListHooks(context.Context, string, scm.ListOptions) ([]*scm.Hook, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) ListStatus(context.Context, string, string, scm.ListOptions) ([]*scm.Status, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) CreateHook(context.Context, string, *scm.HookInput) (*scm.Hook, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) CreateStatus(context.Context, string, string, *scm.StatusInput) (*scm.Status, *scm.Response, error) {
panic("implement me")
}
func (s *repositoryService) DeleteHook(context.Context, string, string) (*scm.Response, error) {
panic("implement me")
}