rgitlabremotes

How to use `remotes::install_gitlab` to install from a branch?


I wanted to install the interp package from the "spline" branch in the Gitlab repository at https://gitlab.aau.at/agebhard/interp . When I select that branch on the web page, the URL changes to https://gitlab.aau.at/agebhard/interp/-/tree/spline . However, using that URL in the obvious way gives an error:

remotes::install_gitlab("agebhard/interp", 
                        subdir = "-/tree/spline", 
                        host = "https://gitlab.aau.at")
#> Error: Failed to install 'unknown package' from GitLab:
#>   cannot open URL 'https://gitlab.aau.at/api/v4/projects/agebhard%2Finterp/repository/files/-%2Ftree%2Fspline%2FDESCRIPTION/raw?ref=HEAD'

Created on 2022-02-09 by the reprex package (v2.0.1.9000)

I ended up cloning the whole repository and then using git branch to select the branch, and installing locally. But surely remotes::install_gitlab() would offer a way to install directly from a branch? The install_github() function has ref to select a branch or tag, but I don't see an equivalent of that argument in install_gitlab().


Solution

  • You can use just install_git

    remotes::install_git(
      url = "https://gitlab.aau.at/agebhard/interp.git",
      ref = "spline"
    )