Skip to content

Commit

Permalink
Merge pull request #116 from ThinkR-open/subgroups
Browse files Browse the repository at this point in the history
Add Subgroups
  • Loading branch information
statnmap authored May 15, 2024
2 parents e099b0e + 4491605 commit 480a14a
Show file tree
Hide file tree
Showing 40 changed files with 933 additions and 584 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: gitlabr
Title: Access to the 'Gitlab' API
Version: 2.0.1.9004
Title: Access to the 'GitLab' API
Version: 2.0.1.9006
Authors@R: c(
person("Jirka", "Lewandowski", , "[email protected]", role = "aut"),
person("Sébastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
person("Sébastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1565-9313"))
)
Description: Provides R functions to access the API of the project and
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export(gl_list_user_projects)
export(gl_new_group)
export(gl_new_issue)
export(gl_new_project)
export(gl_new_subgroup)
export(gl_pipelines)
export(gl_proj_req)
export(gl_project_connection)
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
## New features

* `gl_new_group()`, `gl_edit_group()`, `gl_delete_group()`, `gl_list_groups()`, `gl_list_sub_groups()` to deal with groups on a GitLab instance (@mpolano)
* `gl_new_subgroup()` to create a subgroup in a group (@margotbrd)
* `gl_delete_file()` to delete a file in a repository
* `gl_list_project_members()` and `gl_list_group_members` to retrieve members of a project or a group (#61, @datawookie)
* `gitlab()` queries allow for a vector of parameters to be passed to the API. This is needed when the API asks for an array (@klmr)
Expand Down Expand Up @@ -72,7 +73,7 @@

# gitlabr 0.9 (2017-04-24)

* Support for Gitlab API v4 (default from Gitlab version 9.0 onward) was added. Gitlab API v4 is now the default used by gitlabr, but using the old API (v3) is still possible, see details section "API version" of the documentation of `gl_connection`.
* Support for GitLab API v4 (default from GitLab version 9.0 onward) was added. GitLab API v4 is now the default used by gitlabr, but using the old API (v3) is still possible, see details section "API version" of the documentation of `gl_connection`.
* Several convenience functions now have a `force_api_v3` parameter to force old API version logic.
* Issues are now identified by project-wide id and not global iid, according to API v4 logic.
* Function `gl_builds` was replaced by `gl_pipelines` and `gl_jobs` to reflect API v4 logic.
Expand All @@ -83,7 +84,7 @@

# gitlabr 0.8

*There is no gitlabr 0.8. Version number 0.9 was used to align with Gitlab version 9.0, for which this version is appropriate.*
*There is no gitlabr 0.8. Version number 0.9 was used to align with GitLab version 9.0, for which this version is appropriate.*

# gitlabr 0.7 (2017-03-06)

Expand Down
60 changes: 35 additions & 25 deletions R/branches.R
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
#' List, create and delete branches
#'
#'
#' @rdname branches
#' @param project name or id of project (not repository!)
#' @param ... passed on to [gitlab()]
#' @export
#' @return Tibble of branches available in the project with descriptive variables
#' @examples \dontrun{
#' set_gitlab_connection(gitlab_url = "https://gitlab.com",
#' private_token = Sys.getenv("GITLAB_COM_TOKEN"))
#' set_gitlab_connection(
#' gitlab_url = "https://gitlab.com",
#' private_token = Sys.getenv("GITLAB_COM_TOKEN")
#' )
#' project_id <- ... ## Fill in your project ID
#'
#'
#' # List branches of the project
#' gl_list_branches(project_ = "<<your-project-id>>")
#' gl_list_branches(project_ = "<<your-project-id>>")
#' # Create branch "new_feature"
#' gl_create_branch(project = "<<your-project-id>>",
#' branch = "new_feature")
#' gl_create_branch(
#' project = "<<your-project-id>>",
#' branch = "new_feature"
#' )
#' # Confirm that the branch was created
#' gl_get_branch("<<your-project-id>>", branch = "new_feature")
#' # List all branches - this may take some time before your branch really appears there
#' gl_list_branches(project = "<<your-project-id>>")
#' # Delete branch again
#' gl_delete_branch(project = "<<your-project-id>>",
#' branch = "new_feature")
#' gl_delete_branch(
#' project = "<<your-project-id>>",
#' branch = "new_feature"
#' )
#' # Check that we're back where we started
#' gl_list_branches(project = "<<your-project-id>>")
#' }
gl_list_branches <- function(project, ...) {
gl_proj_req(project, c("repository", "branches"), ...) %>%
gl_proj_req(project, c("repository", "branches"), ...) %>%
gitlab(...)
}

#' @rdname branches
#' @export
gl_get_branch <- function(project, branch, ...) {
gl_proj_req(project, c("repository", "branches", branch), ...) %>%
gl_proj_req(project, c("repository", "branches", branch), ...) %>%
gitlab(...)
}

Expand All @@ -42,24 +48,28 @@ gl_get_branch <- function(project, branch, ...) {
#' @rdname branches
#' @export
gl_create_branch <- function(project, branch, ref = get_main(), ...) {
gl_proj_req(project, c("repository", "branches"), ...) %>%
gitlab(verb = httr::POST,
branch_name = branch, ## This is legacy for API v3 use and will be ignored by API v4
branch = branch,
ref = ref,
auto_format = TRUE,
...) #%>%
# tibble::as_tibble()
gl_proj_req(project, c("repository", "branches"), ...) %>%
gitlab(
verb = httr::POST,
branch_name = branch, ## This is legacy for API v3 use and will be ignored by API v4
branch = branch,
ref = ref,
auto_format = TRUE,
...
) # %>%
# tibble::as_tibble()
}

#' List, create and delete branches
#'
#'
#' @rdname branches
#' @export
gl_delete_branch <- function(project, branch, ...) {
gl_proj_req(project, c("repository", "branches", branch), ...) %>%
gitlab(verb = httr::DELETE,
auto_format = TRUE,
...) #%>%
# tibble::as_tibble()
gl_proj_req(project, c("repository", "branches", branch), ...) %>%
gitlab(
verb = httr::DELETE,
auto_format = TRUE,
...
) # %>%
# tibble::as_tibble()
}
Loading

0 comments on commit 480a14a

Please sign in to comment.