forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 83
/
git.go
68 lines (54 loc) · 2.04 KB
/
git.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
package fake
import (
"context"
"fmt"
"strings"
"github.com/jenkins-x/go-scm/scm"
)
type gitService struct {
client *wrapper
data *Data
}
func (s *gitService) FindRef(ctx context.Context, repo, ref string) (string, *scm.Response, error) {
f := s.data
return f.TestRef, nil, nil
}
func (s *gitService) CreateRef(ctx context.Context, repo, ref, sha string) (*scm.Reference, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) DeleteRef(ctx context.Context, repo, ref string) (*scm.Response, error) {
f := s.data
paths := strings.SplitN(repo, "/", 2)
if len(paths) < 2 {
return nil, fmt.Errorf("repository string '%s' should contain two words separated by '/'", repo)
}
org := paths[0]
name := paths[1]
f.RefsDeleted = append(f.RefsDeleted, DeletedRef{Org: org, Repo: name, Ref: ref})
return nil, nil
}
func (s *gitService) FindBranch(ctx context.Context, repo, name string) (*scm.Reference, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) FindCommit(ctx context.Context, repo, sha string) (*scm.Commit, *scm.Response, error) {
f := s.data
return f.Commits[sha], nil, nil
}
func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Reference, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) ListBranches(ctx context.Context, repo string, opts *scm.ListOptions) ([]*scm.Reference, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) ListCommits(ctx context.Context, repo string, opts scm.CommitListOptions) ([]*scm.Commit, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) ListChanges(ctx context.Context, repo, ref string, opts *scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) CompareCommits(ctx context.Context, repo, ref1, ref2 string, opts *scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
panic("implement me")
}
func (s *gitService) ListTags(ctx context.Context, repo string, opts *scm.ListOptions) ([]*scm.Reference, *scm.Response, error) {
panic("implement me")
}