Skip to content

Commit

Permalink
Merge pull request #105 from ThinkR-open/rebase-datawookie-main
Browse files Browse the repository at this point in the history
Rebase datawookie main
  • Loading branch information
statnmap authored May 31, 2023
2 parents 03c4703 + 5f24c96 commit 02fe9d3
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ export(gl_jobs)
export(gl_latest_build_artifact)
export(gl_list_branches)
export(gl_list_files)
export(gl_list_group_members)
export(gl_list_group_projects)
export(gl_list_issues)
export(gl_list_merge_requests)
export(gl_list_project_members)
export(gl_list_projects)
export(gl_list_user_projects)
export(gl_new_issue)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ New features

* Connection now uses the token as "header" instead of being sent clearly in the URL (#66, @ei-ds)
* `gl_list_group_projects()` lists projects of a group (@Yoshinobu-Ishizaki)
* `gl_list_project_members()` and `gl_list_group_members` to retrieve members of a project or a group (#61, @datawookie)

Minor changes

* doc HTML5 re-created with last version of roxygen2


# gitlabr 2.0.0

Breaking changes
Expand Down
41 changes: 40 additions & 1 deletion R/projects_and_repos.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ gl_proj_req <- function(project, req, ...) {
#' }
gl_get_project_id <- function(project_name, ...) {

matching <- gitlab(req = "projects", ...) %>%
if (is.null(list(...)$simple)) {
req <- gitlab(req = "projects", ..., simple = TRUE)
} else {
req <- gitlab(req = "projects", ...)
}


matching <- req %>%
mutate(matches_name = name == project_name,
matches_path = path == project_name,
matches_path_with_namespace = path_with_namespace == project_name) %>%
Expand Down Expand Up @@ -265,3 +272,35 @@ gl_delete_project <- function(project) {
gitlab(req = c("projects", to_project_id(project)),
verb = httr::DELETE)
}

#' List members of a specific project
#' @param project The ID or URL-encoded path of the project.
#' @param ... passed on to [gitlab()] API call for "project"
#'
#' @export
#' @examples \dontrun{
#' set_gitlab_connection(
#' gitlab_url = "https://gitlab.com",
#' private_token = Sys.getenv("GITLAB_COM_TOKEN")
#' )
#' gl_list_project_members(project = "<<your-project-id>>")
#' }
gl_list_project_members <- function(project, ...) {
gitlab(req = c("projects", to_project_id(project), "members"))
}

#' List members of a specific group
#' @param group The ID or URL-encoded path of the group
#' @param ... passed on to [gitlab()] API call for "groups"
#'
#' @export
#' @examples \dontrun{
#' set_gitlab_connection(
#' gitlab_url = "https://gitlab.com",
#' private_token = Sys.getenv("GITLAB_COM_TOKEN")
#' )
#' gl_list_group_members(group = "<<your-group-id>>")
#' }
gl_list_group_members <- function(group, ...) {
gitlab(req = c("groups", group, "members"))
}
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ reference:
- gl_reopen_issue
- gl_repository
- gl_unassign_issue
- gl_list_group_members
- gl_list_project_members
- title: Set global options
desc: >
Define connection to an instance of GitLab
Expand Down
12 changes: 12 additions & 0 deletions dev/config_attachment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
path.n: NAMESPACE
path.d: DESCRIPTION
dir.r: R
dir.v: vignettes
dir.t: tests
extra.suggests: ~
pkg_ignore: ~
document: yes
normalize: yes
inside_rmd: no
must.exist: yes
check_if_suggests_is_installed: yes
2 changes: 1 addition & 1 deletion dev/dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pkgdown::build_site()
attachment::att_amend_desc() #extra.suggests = "glue")
devtools::load_all()
devtools::test()
devtools::check() # /!\ Tests are currently skip /!\
devtools::check() # /!\ Tests are currently skip if no token in "dev/environment.yml"/!\
devtools::build_vignettes()


Expand Down
25 changes: 25 additions & 0 deletions man/gl_list_group_members.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions man/gl_list_project_members.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions tests/testthat/test_projects_repos.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ test_that("gl_proj_req works", {
# gl_get_project_id ----
# Can not be really tested because gitlab.com is too big
# except with user namespace ? No
# gl_get_project_id(paste0(all_user_projects$namespace.path[1], "testor"), max_page = 3)
# gitlab(req = "projects", gitlab_url = file.path(test_url, all_user_projects$namespace.path[1]), max_page = 1)

# => Assume that the last modified is the current project
# because of unit tests
the_retrieved_id <- gl_get_project_id(test_project_name,
max_page = 3, owned = TRUE,
order_by = "last_activity_at")
# gitlab(req = "projects",
# gitlab_url = file.path(test_url, all_user_projects$namespace.path[1]),
# max_page = 1, owned = TRUE)
test_that("gl_get_project_id works", {
expect_equal(as.character(the_retrieved_id), test_project_id)
})
# gl_archive ----
# Dont want to test archiving project

Expand Down

0 comments on commit 02fe9d3

Please sign in to comment.