feat(repos): add repository permission lookup
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
232c1fa943
commit
48c6296d25
2 changed files with 18 additions and 0 deletions
10
repos.go
10
repos.go
|
|
@ -282,6 +282,16 @@ func (s *RepoService) GetCollaboratorPermission(ctx context.Context, owner, repo
|
|||
return &out, nil
|
||||
}
|
||||
|
||||
// GetRepoPermissions returns repository permissions for a user.
|
||||
func (s *RepoService) GetRepoPermissions(ctx context.Context, owner, repo, collaborator string) (*types.RepoCollaboratorPermission, error) {
|
||||
path := ResolvePath("/api/v1/repos/{owner}/{repo}/collaborators/{collaborator}/permission", pathParams("owner", owner, "repo", repo, "collaborator", collaborator))
|
||||
var out types.RepoCollaboratorPermission
|
||||
if err := s.client.Get(ctx, path, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
// GetArchive returns a repository archive as raw bytes.
|
||||
func (s *RepoService) GetArchive(ctx context.Context, owner, repo, archive string) ([]byte, error) {
|
||||
path := ResolvePath("/api/v1/repos/{owner}/{repo}/archive/{archive}", pathParams("owner", owner, "repo", repo, "archive", archive))
|
||||
|
|
|
|||
|
|
@ -1607,6 +1607,14 @@ func TestRepoService_GetCollaboratorPermission_Good(t *testing.T) {
|
|||
if perm.Permission != "write" || perm.User == nil || perm.User.UserName != "alice" {
|
||||
t.Fatalf("got %#v", perm)
|
||||
}
|
||||
|
||||
perm, err = f.Repos.GetRepoPermissions(context.Background(), "core", "go-forge", "alice")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if perm.Permission != "write" || perm.User == nil || perm.User.UserName != "alice" {
|
||||
t.Fatalf("got %#v", perm)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepoService_Watch_Good(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue