-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move list_team_*() functions to own file
- Loading branch information
Showing
4 changed files
with
64 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#' List members of a GitHub Team | ||
#' | ||
#' @inheritParams add_team_members | ||
#' @param names_only Should only the team member names be returned (as a character vector; `TRUE`, the default), | ||
#' or should all of the team member metadata be returned? | ||
#' @param ... passed on to [gh::gh()] | ||
#' | ||
#' @return a character vector of team member GitHub usernames if `names_only = TRUE`, otherwise | ||
#' a `gh_response` object containing team member information | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes") | ||
#' list_team_members(team = "2023-superdogs-test-cohort", org = "openscapes", names_only = FALSE) | ||
#' } | ||
list_team_members <- function(team, org = "openscapes", names_only = TRUE, ...) { | ||
check_gh_pat() | ||
|
||
org_teams <- list_teams(org) | ||
|
||
if (!team %in% org_teams) { | ||
stop("'", team, "' is not part of the '", org, "' organization", | ||
call. = FALSE) | ||
} | ||
|
||
team_members <- gh( | ||
"GET /orgs/{org}/teams/{team_slug}/members", | ||
org = org, | ||
team_slug = team, | ||
... | ||
) | ||
|
||
if (!names_only) return(team_members) | ||
|
||
vapply(team_members, `[[`, FUN.VALUE = character(1), "login") | ||
} | ||
|
||
#' List teams in a GitHub organization | ||
#' | ||
#' @inheritParams list_team_members | ||
#' @param names_only Should only the team names be returned (as a character vector; `TRUE`, the default), | ||
#' or should all of the team metadata be returned? | ||
#' | ||
#' @return a character vector of team names if `names_only = TRUE`, otherwise | ||
#' a `gh_response` object containing team information | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' list_teams(org = "openscapes") | ||
#' list_teams(org = "openscapes", names_only = FALSE) | ||
#' } | ||
list_teams <- function(org = "openscapes", names_only = TRUE, ...) { | ||
check_gh_pat() | ||
|
||
teams <- gh("GET /orgs/{org}/teams", org = org) | ||
|
||
if (!names_only) return(teams) | ||
|
||
vapply(teams, `[[`, FUN.VALUE = character(1), "name") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.