Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Fix check for team membership. Bump version #32

Merged
merged 2 commits into from
Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/spf13/viper"
)

const atlantisVersion = "0.9.0-cp.1"
const atlantisVersion = "0.9.0-cp.2+2019-10-13T21:00:00+00:00"

func main() {
v := viper.New()
Expand Down
13 changes: 5 additions & 8 deletions server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (g *GithubClient) MergePull(pull models.PullRequest) error {
}

// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
// https://developer.github.com/v3/teams/members/#get-team-membership
func (g *GithubClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
var teamNames []string
opts := &github.ListOptions{}
Expand All @@ -232,14 +233,10 @@ func (g *GithubClient) GetTeamNamesForUser(repo models.Repo, user models.User) (
}
for _, t := range teams {
membership, _, err := g.client.Teams.GetTeamMembership(g.ctx, t.GetID(), user.Username)
if err != nil {
return nil, err
}
if membership == nil {
return nil, errors.New("Failed to get Team membership for user")
}
if *membership.Role == "member" || *membership.Role == "maintainer" {
teamNames = append(teamNames, t.GetName())
if err == nil && membership != nil {
if *membership.State == "active" && (*membership.Role == "member" || *membership.Role == "maintainer") {
teamNames = append(teamNames, t.GetName())
}
}
}
if resp.NextPage == 0 {
Expand Down