Skip to content

Commit

Permalink
Merge pull request #299 from manuelstein/fix-gitlab-add-collaborator
Browse files Browse the repository at this point in the history
gitlab: AddCollaborator tell when user is a member
  • Loading branch information
jenkins-x-bot committed Aug 31, 2023
2 parents 218168b + 3bfe234 commit 1a237c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scm/driver/gitlab/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,15 @@ func (s *repositoryService) AddCollaborator(ctx context.Context, repo, username,
AccessLevel: stringToAccessLevel(permission),
}
res, err := s.client.do(ctx, "POST", path, in, &out)
if res.Status == 409 {
// GitLab returns 409 Conflict and message "Member already exists"
return false, true, res, err
}
if err != nil {
return false, false, res, err
}
return true, false, res, nil
// Return that user has become a member already (no invite/accept in GitLab)
return true, true, res, nil
}

func (s *repositoryService) IsCollaborator(ctx context.Context, repo, user string) (bool, *scm.Response, error) {
Expand Down

0 comments on commit 1a237c8

Please sign in to comment.