@@ -18,6 +18,9 @@ type gitService struct {
18
18
19
19
func (s * gitService ) CreateBranch (ctx context.Context , repo string , params * scm.CreateBranch ) (* scm.Response , error ) {
20
20
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/update-refs?view=azure-devops-rest-6.0
21
+ if s .client .project == "" {
22
+ return nil , ProjectRequiredError ()
23
+ }
21
24
endpoint := fmt .Sprintf ("%s/%s/_apis/git/repositories/%s/refs?api-version=6.0" , s .client .owner , s .client .project , repo )
22
25
23
26
in := make (crudBranch , 1 )
@@ -28,11 +31,17 @@ func (s *gitService) CreateBranch(ctx context.Context, repo string, params *scm.
28
31
}
29
32
30
33
func (s * gitService ) FindBranch (ctx context.Context , repo , name string ) (* scm.Reference , * scm.Response , error ) {
34
+ if s .client .project == "" {
35
+ return nil , nil , ProjectRequiredError ()
36
+ }
31
37
return nil , nil , scm .ErrNotSupported
32
38
}
33
39
34
40
func (s * gitService ) FindCommit (ctx context.Context , repo , ref string ) (* scm.Commit , * scm.Response , error ) {
35
41
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get?view=azure-devops-rest-6.0#get-by-id
42
+ if s .client .project == "" {
43
+ return nil , nil , ProjectRequiredError ()
44
+ }
36
45
endpoint := fmt .Sprintf ("%s/%s/_apis/git/repositories/%s/commits/%s?api-version=6.0" , s .client .owner , s .client .project , repo , ref )
37
46
out := new (gitCommit )
38
47
res , err := s .client .do (ctx , "GET" , endpoint , nil , out )
@@ -45,6 +54,9 @@ func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Refer
45
54
46
55
func (s * gitService ) ListBranches (ctx context.Context , repo string , _ scm.ListOptions ) ([]* scm.Reference , * scm.Response , error ) {
47
56
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-6.0
57
+ if s .client .project == "" {
58
+ return nil , nil , ProjectRequiredError ()
59
+ }
48
60
endpoint := fmt .Sprintf ("%s/%s/_apis/git/repositories/%s/refs?api-version=6.0" , s .client .owner , s .client .project , repo )
49
61
out := new (branchList )
50
62
res , err := s .client .do (ctx , "GET" , endpoint , nil , & out )
@@ -53,6 +65,9 @@ func (s *gitService) ListBranches(ctx context.Context, repo string, _ scm.ListOp
53
65
54
66
func (s * gitService ) ListCommits (ctx context.Context , repo string , opts scm.CommitListOptions ) ([]* scm.Commit , * scm.Response , error ) {
55
67
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits?view=azure-devops-rest-6.0
68
+ if s .client .project == "" {
69
+ return nil , nil , ProjectRequiredError ()
70
+ }
56
71
endpoint := fmt .Sprintf ("%s/%s/_apis/git/repositories/%s/commits?" , s .client .owner , s .client .project , repo )
57
72
if opts .Ref != "" {
58
73
endpoint += fmt .Sprintf ("searchCriteria.itemVersion.version=%s&" , opts .Ref )
@@ -77,6 +92,9 @@ func (s *gitService) ListChanges(ctx context.Context, repo, ref string, _ scm.Li
77
92
78
93
func (s * gitService ) CompareChanges (ctx context.Context , repo , source , target string , _ scm.ListOptions ) ([]* scm.Change , * scm.Response , error ) {
79
94
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-6.0
95
+ if s .client .project == "" {
96
+ return nil , nil , ProjectRequiredError ()
97
+ }
80
98
endpoint := fmt .Sprintf ("%s/%s/_apis/git/repositories/%s/diffs/commits?" , s .client .owner , s .client .project , repo )
81
99
// add base
82
100
endpoint += fmt .Sprintf ("baseVersion=%s&baseVersionType=commit&" , source )
0 commit comments