8
8
"context"
9
9
"fmt"
10
10
"net/url"
11
+ "strings"
11
12
12
13
"github.com/drone/go-scm/scm"
13
14
)
@@ -28,7 +29,7 @@ func (s *RepositoryService) Find(ctx context.Context, repo string) (*scm.Reposit
28
29
29
30
out := new (repository )
30
31
res , err := s .client .do (ctx , "GET" , endpoint , nil , & out )
31
- return convertRepository (out ), res , err
32
+ return convertRepository (out , s . client . owner ), res , err
32
33
}
33
34
34
35
// FindHook returns a repository hook.
@@ -53,7 +54,7 @@ func (s *RepositoryService) List(ctx context.Context, opts scm.ListOptions) ([]*
53
54
54
55
out := new (repositories )
55
56
res , err := s .client .do (ctx , "GET" , endpoint , nil , & out )
56
- return convertRepositoryList (out ), res , err
57
+ return convertRepositoryList (out , s . client . owner ), res , err
57
58
}
58
59
59
60
// ListV2 returns the user repository list.
@@ -261,25 +262,27 @@ type subscription struct {
261
262
URL string `json:"url"`
262
263
}
263
264
264
- // helper function to convert from the gogs repository list to
265
+ // helper function to convert from the azure devops repository list to
265
266
// the common repository structure.
266
- func convertRepositoryList (from * repositories ) []* scm.Repository {
267
+ func convertRepositoryList (from * repositories , owner string ) []* scm.Repository {
267
268
to := []* scm.Repository {}
268
269
for _ , v := range from .Value {
269
- to = append (to , convertRepository (v ))
270
+ to = append (to , convertRepository (v , owner ))
270
271
}
271
272
return to
272
273
}
273
274
274
- // helper function to convert from the gogs repository structure
275
+ // helper function to convert from the azure devops repository structure
275
276
// to the common repository structure.
276
- func convertRepository (from * repository ) * scm.Repository {
277
+ func convertRepository (from * repository , owner string ) * scm.Repository {
278
+ namespace := []string {owner , from .Project .Name }
277
279
return & scm.Repository {
278
- ID : from .ID ,
279
- Name : from .Name ,
280
- Link : from .URL ,
281
- Branch : scm .TrimRef (from .DefaultBranch ),
282
- Clone : from .RemoteURL ,
280
+ ID : from .ID ,
281
+ Name : from .Name ,
282
+ Namespace : strings .Join (namespace , "/" ),
283
+ Link : from .URL ,
284
+ Branch : scm .TrimRef (from .DefaultBranch ),
285
+ Clone : from .RemoteURL ,
283
286
}
284
287
}
285
288
0 commit comments