diff --git a/repos.go b/repos.go index 1fc4e7b..447b11f 100644 --- a/repos.go +++ b/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)) diff --git a/repos_test.go b/repos_test.go index 85a85a6..fb8d114 100644 --- a/repos_test.go +++ b/repos_test.go @@ -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) {