From 8df5dda8162825bc14cea3d32a9ba0db0e1c1056 Mon Sep 17 00:00:00 2001 From: Derek Jobst Date: Wed, 5 May 2021 19:55:10 -0700 Subject: [PATCH 1/5] Adds Permissions to Team --- github/teams.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/github/teams.go b/github/teams.go index 592a11fd848..2e1cd3dafe9 100644 --- a/github/teams.go +++ b/github/teams.go @@ -32,6 +32,10 @@ type Team struct { // Permission specifies the default permission for repositories owned by the team. Permission *string `json:"permission,omitempty"` + // Permissions identifies the permissions that a team has on a given + // repository. This is only populated when calling Repositories.ListTeams. + Permissions *map[string]bool `json:"permissions,omitempty"` + // Privacy identifies the level of privacy this team should have. // Possible values are: // secret - only visible to organization owners and members of this team From 6e561ec5f055f6cfaa48302bc6515562fb45952d Mon Sep 17 00:00:00 2001 From: Derek Jobst Date: Wed, 5 May 2021 19:55:23 -0700 Subject: [PATCH 2/5] Adds GetPermissions method to Team --- github/github-accessors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 37ddb180d8f..081083415b3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14276,6 +14276,14 @@ func (t *Team) GetPermission() string { return *t.Permission } +// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. +func (t *Team) GetPermissions() map[string]bool { + if t == nil || t.Permissions == nil { + return map[string]bool{} + } + return *t.Permissions +} + // GetPrivacy returns the Privacy field if it's non-nil, zero value otherwise. func (t *Team) GetPrivacy() string { if t == nil || t.Privacy == nil { From bf0def29c4fa45d5cdb181e54723c4a8a5fb00b8 Mon Sep 17 00:00:00 2001 From: Derek Jobst Date: Thu, 6 May 2021 09:22:19 -0700 Subject: [PATCH 3/5] Converts Permissions map pointer to map Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/teams.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/teams.go b/github/teams.go index 2e1cd3dafe9..67106d1d595 100644 --- a/github/teams.go +++ b/github/teams.go @@ -34,7 +34,7 @@ type Team struct { // Permissions identifies the permissions that a team has on a given // repository. This is only populated when calling Repositories.ListTeams. - Permissions *map[string]bool `json:"permissions,omitempty"` + Permissions map[string]bool `json:"permissions,omitempty"` // Privacy identifies the level of privacy this team should have. // Possible values are: From 5c30ef9f9382b5cfea673c8d837d8032bdd5e6b2 Mon Sep 17 00:00:00 2001 From: Derek Jobst Date: Thu, 6 May 2021 09:28:25 -0700 Subject: [PATCH 4/5] Removes GetPermissions accessor --- github/github-accessors.go | 8 -------- github/github-stringify_test.go | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 081083415b3..37ddb180d8f 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14276,14 +14276,6 @@ func (t *Team) GetPermission() string { return *t.Permission } -// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. -func (t *Team) GetPermissions() map[string]bool { - if t == nil || t.Permissions == nil { - return map[string]bool{} - } - return *t.Permissions -} - // GetPrivacy returns the Privacy field if it's non-nil, zero value otherwise. func (t *Team) GetPrivacy() string { if t == nil || t.Privacy == nil { diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 71da5cc49b5..3d161b661dc 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1584,6 +1584,7 @@ func TestTeam_String(t *testing.T) { URL: String(""), Slug: String(""), Permission: String(""), + Permissions: nil, Privacy: String(""), MembersCount: Int(0), ReposCount: Int(0), @@ -1593,7 +1594,7 @@ func TestTeam_String(t *testing.T) { Parent: &Team{}, LDAPDN: String(""), } - want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}` + want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Permissions:map[], Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}` if got := v.String(); got != want { t.Errorf("Team.String = %v, want %v", got, want) } From 66fa351f9ec1fa79acf8867299146c1d72c63a02 Mon Sep 17 00:00:00 2001 From: Derek Jobst Date: Thu, 6 May 2021 09:45:29 -0700 Subject: [PATCH 5/5] Adds back pointer to Permissions, fixes tests --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/github-stringify_test.go | 3 +-- github/teams.go | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 37ddb180d8f..081083415b3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14276,6 +14276,14 @@ func (t *Team) GetPermission() string { return *t.Permission } +// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. +func (t *Team) GetPermissions() map[string]bool { + if t == nil || t.Permissions == nil { + return map[string]bool{} + } + return *t.Permissions +} + // GetPrivacy returns the Privacy field if it's non-nil, zero value otherwise. func (t *Team) GetPrivacy() string { if t == nil || t.Privacy == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 3da8dda1037..49ceb123953 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16730,6 +16730,16 @@ func TestTeam_GetPermission(tt *testing.T) { t.GetPermission() } +func TestTeam_GetPermissions(tt *testing.T) { + var zeroValue map[string]bool + t := &Team{Permissions: &zeroValue} + t.GetPermissions() + t = &Team{} + t.GetPermissions() + t = nil + t.GetPermissions() +} + func TestTeam_GetPrivacy(tt *testing.T) { var zeroValue string t := &Team{Privacy: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 3d161b661dc..71da5cc49b5 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1584,7 +1584,6 @@ func TestTeam_String(t *testing.T) { URL: String(""), Slug: String(""), Permission: String(""), - Permissions: nil, Privacy: String(""), MembersCount: Int(0), ReposCount: Int(0), @@ -1594,7 +1593,7 @@ func TestTeam_String(t *testing.T) { Parent: &Team{}, LDAPDN: String(""), } - want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Permissions:map[], Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}` + want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}` if got := v.String(); got != want { t.Errorf("Team.String = %v, want %v", got, want) } diff --git a/github/teams.go b/github/teams.go index 67106d1d595..2e1cd3dafe9 100644 --- a/github/teams.go +++ b/github/teams.go @@ -34,7 +34,7 @@ type Team struct { // Permissions identifies the permissions that a team has on a given // repository. This is only populated when calling Repositories.ListTeams. - Permissions map[string]bool `json:"permissions,omitempty"` + Permissions *map[string]bool `json:"permissions,omitempty"` // Privacy identifies the level of privacy this team should have. // Possible values are: