diff --git a/DESCRIPTION b/DESCRIPTION index f030176..889426d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: sourcehut Type: Package Title: Tools to Work with the SourceHut Development Ecosystem -Version: 0.1.0 -Date: 2019-09-02 +Version: 0.2.0 +Date: 2019-09-17 Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")) ) Maintainer: Bob Rudis @@ -15,6 +15,6 @@ Encoding: UTF-8 License: MIT + file LICENSE Suggests: covr, tinytest Depends: R (>= 3.2.0) -Imports: httr, jsonlite, usethis, crayon, desc, rprojroot, glue, utils +Imports: httr, jsonlite, usethis, crayon, desc, rprojroot, glue, utils, remotes Roxygen: list(markdown = TRUE) RoxygenNote: 6.1.1 diff --git a/NAMESPACE b/NAMESPACE index 07562b3..062c515 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(get_build_manifest) export(get_build_status) export(git_repos) export(git_user) +export(install_sourcehut) export(meta_audit) export(meta_pgp_keys) export(meta_profile) @@ -24,4 +25,5 @@ importFrom(crayon,blue) importFrom(crayon,make_style) importFrom(desc,desc_get) importFrom(jsonlite,fromJSON) +importFrom(remotes,install_git) importFrom(utils,browseURL) diff --git a/R/install-sourcehut.R b/R/install-sourcehut.R new file mode 100644 index 0000000..2f94435 --- /dev/null +++ b/R/install-sourcehut.R @@ -0,0 +1,18 @@ +#' Install a package from a SourceHut git repository +#' +#' Works like [remotes::install_gitlab()], [remotes::install_bitbucket()], [remotes::install_github()] (etc). +#' You can also omit the leading tilde ("~") from the username portion of the repository address +#' +#' @param repo Repository address in the format `username/repo`. You can specify `subdir` and/or `ref` using the +#' respective parameters (via `...`). +#' @param ... passed on to [remotes::install_git()] +#' @export +install_sourcehut <- function(repo, ...) { + + repo <- repo[1] + + if (!startsWith(repo, "~")) repo <- glue::glue("~{repo}") + + remotes::install_git(url = glue::glue("https://git.sr.ht/{repo}"), ...) + +} \ No newline at end of file diff --git a/R/sourcehut-package.R b/R/sourcehut-package.R index 23982cd..1cdf329 100644 --- a/R/sourcehut-package.R +++ b/R/sourcehut-package.R @@ -11,4 +11,5 @@ #' @import httr usethis crayon desc rprojroot glue #' @importFrom jsonlite fromJSON #' @importFrom utils browseURL +#' @importFrom remotes install_git "_PACKAGE" diff --git a/README.md b/README.md index 31d7ee3..465f458 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ The following functions are implemented: - `git_repos`: Retrieve metadata about repositories - `git_user`: Retrieve metadata about yourself or another SourceHut user + - `install_sourcehut`: Install a package from a SourceHut git + repository - `meta_audit`: Retrieve your audit log - `meta_profile`: Retrieve metadata about yourself - `meta_ssh_keys`: Retrieve your SSH keys @@ -66,15 +68,15 @@ library(sourcehut) # current version packageVersion("sourcehut") -## [1] '0.1.0' +## [1] '0.2.0' ``` ## sourcehut Metrics -| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | -| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | -| R | 15 | 0.94 | 219 | 0.96 | 91 | 0.86 | 105 | 0.79 | -| Rmd | 1 | 0.06 | 8 | 0.04 | 15 | 0.14 | 28 | 0.21 | +| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | +| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | --: | +| R | 16 | 0.94 | 224 | 0.97 | 95 | 0.86 | 115 | 0.8 | +| Rmd | 1 | 0.06 | 8 | 0.03 | 15 | 0.14 | 28 | 0.2 | ## Code of Conduct diff --git a/man/install_sourcehut.Rd b/man/install_sourcehut.Rd new file mode 100644 index 0000000..33d1eec --- /dev/null +++ b/man/install_sourcehut.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/install-sourcehut.R +\name{install_sourcehut} +\alias{install_sourcehut} +\title{Install a package from a SourceHut git repository} +\usage{ +install_sourcehut(repo, ...) +} +\arguments{ +\item{repo}{Repository address in the format \code{username/repo}. You can specify \code{subdir} and/or \code{ref} using the +respective parameters (via \code{...}).} + +\item{...}{passed on to \code{\link[remotes:install_git]{remotes::install_git()}}} +} +\description{ +Works like \code{\link[remotes:install_gitlab]{remotes::install_gitlab()}}, \code{\link[remotes:install_bitbucket]{remotes::install_bitbucket()}}, \code{\link[remotes:install_github]{remotes::install_github()}} (etc). +You can also omit the leading tilde ("~") from the username portion of the repository address +}