Skip to contents

Allows to conveniently work with GitLab’s v4 RESTful API from R. GitLab (https://gitlab.com) is an open-source DevOps software suite that i.a. includes a powerful Git forge.

Installation

To install the latest development version of gitlab, run the following in R:

if (!("remotes" %in% rownames(installed.packages()))) {
  install.packages(pkgs = "remotes",
                   repos = "https://cloud.r-project.org/")
}

remotes::install_gitlab(repo = "rpkg.dev/gitlab")

Usage

The (function) reference is found here.

Package configuration

Some of gitlab’s functionality is controlled via package-specific global configuration which can either be set via R options or environment variables (the former take precedence). This configuration includes:

Description R option Environment variable Default value
Base URL of the GitLab v4 RESTful API server to be accessed when base_url is not explicitly provided to the functions of this package. gitlab.base_url R_GITLAB_BASE_URL "https://gitlab.com/api/v4"
GitLab project identifier to use when id_project is not explicitly provided to the functions of this package. gitlab.id_project R_GITLAB_ID_PROJECT
GitLab access token used for authentication when token is not explicitly provided to the functions of this package. A personal access token for gitlab.com can be created under this link. gitlab.token R_GITLAB_TOKEN Sys.getenv("GITLAB_COM_TOKEN")

Development

R Markdown format

This package’s source code is written in the R Markdown file format to facilitate practices commonly referred to as literate programming. It allows the actual code to be freely mixed with explanatory and supplementary information in expressive Markdown format instead of having to rely on # comments only.

All the .gen.R suffixed R source code found under R/ is generated from the respective R Markdown counterparts under Rmd/ using pkgpurl::purl_rmd()1. Always make changes only to the .Rmd files – never the .R files – and then run pkgpurl::purl_rmd() to regenerate the R source files.

Coding style

This package borrows a lot of the Tidyverse design philosophies. The R code adheres to the principles specified in the Tidyverse Design Guide wherever possible and is formatted according to the Tidyverse Style Guide (TSG) with the following exceptions:

  • Line width is limited to 160 characters, double the limit proposed by the TSG (80 characters is ridiculously little given today’s high-resolution wide screen monitors).

    Furthermore, the preferred style for breaking long lines differs. Instead of wrapping directly after an expression’s opening bracket as suggested by the TSG, we prefer two fewer line breaks and indent subsequent lines within the expression by its opening bracket:

    # TSG proposes this
    do_something_very_complicated(
      something = "that",
      requires = many,
      arguments = "some of which may be long"
    )
    
    # we prefer this
    do_something_very_complicated(something = "that",
                                  requires = many,
                                  arguments = "some of which may be long")

    This results in less vertical and more horizontal spread of the code and better readability in pipes.

  • Usage of magrittr’s compound assignment pipe-operator %<>% is desirable2.

  • Usage of R’s right-hand assignment operator -> is not allowed3.

  • R source code is not split over several files as suggested by the TSG but instead is (as far as possible) kept in the single file Rmd/gitlab.Rmd which is well-structured thanks to its Markdown support.

As far as possible, these deviations from the TSG plus some additional restrictions are formally specified in pkgpurl::default_linters, which is (by default) used in pkgpurl::lint_rmd(), which in turn is the recommended way to lint this package.