From 76344c50791d3d83f93e385ae15a5a83e41476fa Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Mon, 23 Jun 2014 18:49:06 -0700 Subject: [PATCH 01/17] Added param for alternate github repo path Hoping to get install_github() to work with an enterprise GitHub repo with a different path than https://github.com --- R/install-github.r | 17 +++++++++++------ man/install_github.Rd | 6 +++++- src-i386/devtools.c | 6 ++++++ src-x64/devtools.c | 6 ++++++ 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 src-i386/devtools.c create mode 100644 src-x64/devtools.c diff --git a/R/install-github.r b/R/install-github.r index eb75f65af..59f117fc1 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -25,6 +25,8 @@ #' supply to this argument. This is safer than using a password because #' you can easily delete a PAT without affecting any others. Defaults to #' the \code{GITHUB_PAT} environment variable. +#' @param repo_path -- defaults to "https://github.com/", but can be set +#' to Enterprise GitHub SCM path. #' @param ... Other arguments passed on to \code{\link{install}}. #' @param dependencies By default, installs all dependencies so that you can #' build vignettes and use all functionality of the package. @@ -51,18 +53,20 @@ install_github <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, - auth_token = github_pat(), ..., + auth_token = github_pat(), + repo_path="https://github.com/", ..., dependencies = TRUE) { invisible(vapply(repo, install_github_single, FUN.VALUE = logical(1), - username, ref, pull, subdir, branch, auth_user, password, auth_token, ..., + username, ref, pull, subdir, branch, auth_user, password, + auth_token, repo_path, ..., dependencies = dependencies)) } github_get_conn <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, - auth_token = NULL, ...) { + auth_token = NULL, repo_path="https://github.com/", ...) { if (!is.null(branch)) { warning("'branch' is deprecated. In the future, please use 'ref' instead.") @@ -112,7 +116,7 @@ github_get_conn <- function(repo, username = getOption("github.user"), " from ", paste(username, collapse = ", ")) - url <- paste("https://github.com/", username, "/", repo, + url <- paste(repo_path, username, "/", repo, "/archive/", ref, ".zip", sep = "") list( @@ -125,9 +129,10 @@ github_get_conn <- function(repo, username = getOption("github.user"), install_github_single <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, - password = NULL, auth_token = NULL, ...) { + password = NULL, auth_token = NULL, + repo_path="https://github.com/", ...) { conn <- github_get_conn(repo, username, ref, pull, subdir, branch, - auth_user, password, auth_token, ...) + auth_user, password, auth_token, repo_path, ...) message(conn$msg) # define before_install function that captures the arguments to diff --git a/man/install_github.Rd b/man/install_github.Rd index 90c4defb4..aaddda478 100644 --- a/man/install_github.Rd +++ b/man/install_github.Rd @@ -5,7 +5,8 @@ \usage{ install_github(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, - password = NULL, auth_token = github_pat(), ..., dependencies = TRUE) + password = NULL, auth_token = github_pat(), + repo_path = "https://github.com/", ..., dependencies = TRUE) } \arguments{ \item{repo}{Repository address in the format @@ -39,6 +40,9 @@ supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} +\item{repo_path}{-- defaults to "https://github.com/", but can be set +to Enterprise GitHub SCM path.} + \item{...}{Other arguments passed on to \code{\link{install}}.} \item{dependencies}{By default, installs all dependencies so that you can diff --git a/src-i386/devtools.c b/src-i386/devtools.c new file mode 100644 index 000000000..0955fe872 --- /dev/null +++ b/src-i386/devtools.c @@ -0,0 +1,6 @@ +#include +#include + +SEXP nsreg() { + return R_NamespaceRegistry; +} diff --git a/src-x64/devtools.c b/src-x64/devtools.c new file mode 100644 index 000000000..0955fe872 --- /dev/null +++ b/src-x64/devtools.c @@ -0,0 +1,6 @@ +#include +#include + +SEXP nsreg() { + return R_NamespaceRegistry; +} From e9e19a267343760fe5c2385e913c67cb3183dcf5 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Tue, 24 Jun 2014 13:55:14 -0700 Subject: [PATCH 02/17] Fixed defaults for alternate github repo path --- R/install-github.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/install-github.r b/R/install-github.r index 59f117fc1..4758aa24e 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -130,7 +130,7 @@ install_github_single <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, auth_token = NULL, - repo_path="https://github.com/", ...) { + repo_path=NULL, ...) { conn <- github_get_conn(repo, username, ref, pull, subdir, branch, auth_user, password, auth_token, repo_path, ...) message(conn$msg) From 6e389041c4d1f6bb3fea3cd31dc9ca4b40acbc81 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 25 Jun 2014 09:04:13 -0700 Subject: [PATCH 03/17] Changed repo_path to github_url --- R/install-github.r | 16 ++++++++-------- man/install_github.Rd | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/R/install-github.r b/R/install-github.r index 4758aa24e..0e63e860b 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -25,8 +25,8 @@ #' supply to this argument. This is safer than using a password because #' you can easily delete a PAT without affecting any others. Defaults to #' the \code{GITHUB_PAT} environment variable. -#' @param repo_path -- defaults to "https://github.com/", but can be set -#' to Enterprise GitHub SCM path. +#' @param github_url Defaults to "https://github.com/". You can set it +#' to your custom Enterprise GitHub URL. #' @param ... Other arguments passed on to \code{\link{install}}. #' @param dependencies By default, installs all dependencies so that you can #' build vignettes and use all functionality of the package. @@ -54,19 +54,19 @@ install_github <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, auth_token = github_pat(), - repo_path="https://github.com/", ..., + github_url="https://github.com/", ..., dependencies = TRUE) { invisible(vapply(repo, install_github_single, FUN.VALUE = logical(1), username, ref, pull, subdir, branch, auth_user, password, - auth_token, repo_path, ..., + auth_token, github_url, ..., dependencies = dependencies)) } github_get_conn <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, - auth_token = NULL, repo_path="https://github.com/", ...) { + auth_token = NULL, github_url="https://github.com/", ...) { if (!is.null(branch)) { warning("'branch' is deprecated. In the future, please use 'ref' instead.") @@ -116,7 +116,7 @@ github_get_conn <- function(repo, username = getOption("github.user"), " from ", paste(username, collapse = ", ")) - url <- paste(repo_path, username, "/", repo, + url <- paste(github_url, username, "/", repo, "/archive/", ref, ".zip", sep = "") list( @@ -130,9 +130,9 @@ install_github_single <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, auth_token = NULL, - repo_path=NULL, ...) { + github_url=NULL, ...) { conn <- github_get_conn(repo, username, ref, pull, subdir, branch, - auth_user, password, auth_token, repo_path, ...) + auth_user, password, auth_token, github_url, ...) message(conn$msg) # define before_install function that captures the arguments to diff --git a/man/install_github.Rd b/man/install_github.Rd index aaddda478..9a11318ed 100644 --- a/man/install_github.Rd +++ b/man/install_github.Rd @@ -6,7 +6,7 @@ install_github(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, auth_token = github_pat(), - repo_path = "https://github.com/", ..., dependencies = TRUE) + github_url = "https://github.com/", ..., dependencies = TRUE) } \arguments{ \item{repo}{Repository address in the format @@ -40,8 +40,8 @@ supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} -\item{repo_path}{-- defaults to "https://github.com/", but can be set -to Enterprise GitHub SCM path.} +\item{github_url}{Defaults to "https://github.com/". You can set it +to your custom Enterprise GitHub URL.} \item{...}{Other arguments passed on to \code{\link{install}}.} From 4fa78d31bea4603dea6054f795532050a7e4a3a6 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 25 Jun 2014 10:26:34 -0700 Subject: [PATCH 04/17] Deleted two devtools.c files. --- src-i386/devtools.c | 6 ------ src-x64/devtools.c | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 src-i386/devtools.c delete mode 100644 src-x64/devtools.c diff --git a/src-i386/devtools.c b/src-i386/devtools.c deleted file mode 100644 index 0955fe872..000000000 --- a/src-i386/devtools.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -SEXP nsreg() { - return R_NamespaceRegistry; -} diff --git a/src-x64/devtools.c b/src-x64/devtools.c deleted file mode 100644 index 0955fe872..000000000 --- a/src-x64/devtools.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -SEXP nsreg() { - return R_NamespaceRegistry; -} From 761c8bd5630697d51fcb41194758390a70ccf604 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 25 Jun 2014 22:58:52 -0700 Subject: [PATCH 05/17] Added install_github_enterprise() Uses helper devtools_git_enterprise() --- R/install-github.r | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/R/install-github.r b/R/install-github.r index 0e63e860b..9d1d60d4f 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -63,6 +63,34 @@ install_github <- function(repo, username = getOption("github.user"), dependencies = dependencies)) } +#' Convenience wrapper for \code{\link{install_github}}. +#' +#' This function allows you to install a package built +#' with \code{devtools} from a repo with a custom URL. +#' +#' @export +#' @family package installation +#' @examples +#' \dontrun{ +#' # To install from a private repo, use auth_token as described +#' # at \code{\link{install_github}} and either set \code{github_url} +#' # or let \code{\link{devtools_git_enterprise}} retrieve it from +#' # environment variable GITHUB_URL if it is set. +#' # Best practice is the latter. +#' install_github_enterprise("username/packagename", github_url = "https://github.scm.xyz.com") +#' +#' } +install_github_enterprise <- function(repo, username = getOption("github.user"), + ref = "master", pull = NULL, subdir = NULL, + branch = NULL, auth_user = NULL, password = NULL, + auth_token = github_pat(), + github_url=devtools_git_enterprise(), ..., + dependencies = TRUE) { + install_github(repo, username, ref, pull, subdir, branch, auth_user, password, + auth_token, github_url, ..., + dependencies = dependencies)) +} + github_get_conn <- function(repo, username = getOption("github.user"), ref = "master", pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, password = NULL, @@ -235,6 +263,20 @@ github_parse_path <- function(path) { ret[sapply(ret, nchar) > 0] } +#' Retrieve Enterprise Github URL. +#' +#' Looks in env var \code{GITHUB_URL}. +#' +#' @keywords internal +#' @export +devtools_git_enterprise <- function() { + url <- Sys.getenv('GITHUB_URL') + if (identical(url, "")) return(NULL) + + message("Using custom GitHub URL from envvar GITHUB_URL") + url +} + #' Retrieve Github personal access token. #' #' Looks in env var \code{GITHUB_PAT}. From de5aea56379d4abc22812a56383fa19fbac88c9d Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 25 Jun 2014 23:01:41 -0700 Subject: [PATCH 06/17] Fixed small typo --- R/install-github.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/install-github.r b/R/install-github.r index 9d1d60d4f..364970151 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -88,7 +88,7 @@ install_github_enterprise <- function(repo, username = getOption("github.user"), dependencies = TRUE) { install_github(repo, username, ref, pull, subdir, branch, auth_user, password, auth_token, github_url, ..., - dependencies = dependencies)) + dependencies = dependencies) } github_get_conn <- function(repo, username = getOption("github.user"), From 3b30f91ed4c0c1b415d9ab70e65af787e9ccc51d Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 25 Jun 2014 23:17:14 -0700 Subject: [PATCH 07/17] Markup fixed, links checked, rebuilt Also ran test() and document() anew. --- NAMESPACE | 2 ++ R/install-github.r | 6 +++--- man/devtools_git_enterprise.Rd | 12 ++++++++++++ man/install.Rd | 1 + man/install_bitbucket.Rd | 3 ++- man/install_git.Rd | 1 + man/install_github.Rd | 1 + man/install_github_enterprise.Rd | 33 ++++++++++++++++++++++++++++++++ man/install_gitorious.Rd | 1 + man/install_url.Rd | 1 + man/install_version.Rd | 1 + 11 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 man/devtools_git_enterprise.Rd create mode 100644 man/install_github_enterprise.Rd diff --git a/NAMESPACE b/NAMESPACE index 0ce36ad93..b4cc3831c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -34,6 +34,7 @@ export(dev_meta) export(dev_mode) export(dev_packages) export(devtest) +export(devtools_git_enterprise) export(document) export(eval_clean) export(evalq_clean) @@ -50,6 +51,7 @@ export(install_bitbucket) export(install_deps) export(install_git) export(install_github) +export(install_github_enterprise) export(install_gitorious) export(install_local) export(install_url) diff --git a/R/install-github.r b/R/install-github.r index 364970151..f354f79c7 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -73,9 +73,9 @@ install_github <- function(repo, username = getOption("github.user"), #' @examples #' \dontrun{ #' # To install from a private repo, use auth_token as described -#' # at \code{\link{install_github}} and either set \code{github_url} -#' # or let \code{\link{devtools_git_enterprise}} retrieve it from -#' # environment variable GITHUB_URL if it is set. +#' # at ?install_github and either set the github_url parameter +#' # or let the ?devtools_git_enterprise helper retrieve it from +#' # the GITHUB_URL environment variable if it is set. #' # Best practice is the latter. #' install_github_enterprise("username/packagename", github_url = "https://github.scm.xyz.com") #' diff --git a/man/devtools_git_enterprise.Rd b/man/devtools_git_enterprise.Rd new file mode 100644 index 000000000..e45fcc259 --- /dev/null +++ b/man/devtools_git_enterprise.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2 (4.0.1): do not edit by hand +\name{devtools_git_enterprise} +\alias{devtools_git_enterprise} +\title{Retrieve Enterprise Github URL.} +\usage{ +devtools_git_enterprise() +} +\description{ +Looks in env var \code{GITHUB_URL}. +} +\keyword{internal} + diff --git a/man/install.Rd b/man/install.Rd index 507f898cd..f9b6fe0b8 100644 --- a/man/install.Rd +++ b/man/install.Rd @@ -68,6 +68,7 @@ not always completely possible, see \code{\link{reload}} for caveats. set. Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_url}}; diff --git a/man/install_bitbucket.Rd b/man/install_bitbucket.Rd index f6b4c198c..86a4501b7 100644 --- a/man/install_bitbucket.Rd +++ b/man/install_bitbucket.Rd @@ -38,7 +38,8 @@ install_bitbucket(c("testrepo", "testrepo2")) Bitbucket API docs: \url{https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs} -Other package installation: \code{\link{install_github}}; +Other package installation: \code{\link{install_github_enterprise}}; + \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_url}}; \code{\link{install_version}}; \code{\link{install}} diff --git a/man/install_git.Rd b/man/install_git.Rd index e92794132..5f551dc81 100644 --- a/man/install_git.Rd +++ b/man/install_git.Rd @@ -41,6 +41,7 @@ install_git("git://github.com/hadley/stringr.git", branch = "stringr-0.2") } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_url}}; \code{\link{install_version}}; diff --git a/man/install_github.Rd b/man/install_github.Rd index 9a11318ed..24e6b2c61 100644 --- a/man/install_github.Rd +++ b/man/install_github.Rd @@ -73,6 +73,7 @@ install_github("hadley/private", auth_token = "abc") } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_url}}; \code{\link{install_version}}; \code{\link{install}} diff --git a/man/install_github_enterprise.Rd b/man/install_github_enterprise.Rd new file mode 100644 index 000000000..1eb7f3bf9 --- /dev/null +++ b/man/install_github_enterprise.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2 (4.0.1): do not edit by hand +\name{install_github_enterprise} +\alias{install_github_enterprise} +\title{Convenience wrapper for \code{\link{install_github}}.} +\usage{ +install_github_enterprise(repo, username = getOption("github.user"), + ref = "master", pull = NULL, subdir = NULL, branch = NULL, + auth_user = NULL, password = NULL, auth_token = github_pat(), + github_url = devtools_git_enterprise(), ..., dependencies = TRUE) +} +\description{ +This function allows you to install a package built +with \code{devtools} from a repo with a custom URL. +} +\examples{ +\dontrun{ +# To install from a private repo, use auth_token as described +# at ?install_github and either set the github_url parameter +# or let the ?devtools_git_enterprise helper retrieve it from +# the GITHUB_URL environment variable if it is set. +# Best practice is the latter. +install_github_enterprise("username/packagename", github_url = "https://github.scm.xyz.com") + +} +} +\seealso{ +Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github}}; + \code{\link{install_gitorious}}; + \code{\link{install_git}}; \code{\link{install_url}}; + \code{\link{install_version}}; \code{\link{install}} +} + diff --git a/man/install_gitorious.Rd b/man/install_gitorious.Rd index eb31d9f5b..a9008519b 100644 --- a/man/install_gitorious.Rd +++ b/man/install_gitorious.Rd @@ -30,6 +30,7 @@ install_gitorious("r-mpc-package") } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_git}}; \code{\link{install_url}}; \code{\link{install_version}}; \code{\link{install}} diff --git a/man/install_url.Rd b/man/install_url.Rd index f94da9437..1de6c1641 100644 --- a/man/install_url.Rd +++ b/man/install_url.Rd @@ -31,6 +31,7 @@ a single command. } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_version}}; diff --git a/man/install_version.Rd b/man/install_version.Rd index 3327bc203..e2d368f0f 100644 --- a/man/install_version.Rd +++ b/man/install_version.Rd @@ -53,6 +53,7 @@ Jeremy Stephens } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_url}}; From d2e7ee9a18b65ded9791ac9f1c89dbfae6b2e06a Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Fri, 27 Jun 2014 08:07:42 -0700 Subject: [PATCH 08/17] Deleted the two devtools.c files. --- src-i386/devtools.c | 6 ------ src-x64/devtools.c | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 src-i386/devtools.c delete mode 100644 src-x64/devtools.c diff --git a/src-i386/devtools.c b/src-i386/devtools.c deleted file mode 100644 index 0955fe872..000000000 --- a/src-i386/devtools.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -SEXP nsreg() { - return R_NamespaceRegistry; -} diff --git a/src-x64/devtools.c b/src-x64/devtools.c deleted file mode 100644 index 0955fe872..000000000 --- a/src-x64/devtools.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -SEXP nsreg() { - return R_NamespaceRegistry; -} From 9adbfd27d2d92b21bebcda8d7968a95f2bf72aec Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Fri, 27 Jun 2014 15:42:01 -0700 Subject: [PATCH 09/17] Fixed doc for install_github_enterprise() --- R/install-github.r | 27 +++++++++++++++++++++ man/install_github_enterprise.Rd | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/R/install-github.r b/R/install-github.r index 903698c7c..8a77594b7 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -68,6 +68,33 @@ install_github <- function(repo, username = getOption("github.user"), #' This function allows you to install a package built #' with \code{devtools} from a repo with a custom URL. #' +#' @param repo Repository address in the format +#' \code{[username/]repo[/subdir][@@ref|#pull]}. Alternatively, you can +#' specify \code{username}, \code{subdir}, \code{ref} or \code{pull} using the +#' respective parameters (see below); if both is specified, the values in +#' \code{repo} take precedence. +#' @param username User name +#' @param ref Desired git reference. Could be a commit, tag, or branch +#' name. Defaults to \code{"master"}. +#' @param pull Desired pull request. A pull request refers to a branch, +#' so you can't specify both \code{branch} and \code{pull}; one of +#' them must be \code{NULL}. +#' @param subdir subdirectory within repo that contains the R package. +#' @param branch Deprecated. Use \code{ref} instead. +#' @param auth_user your account username if you're attempting to install +#' a package hosted in a private repository (and your username is different +#' to \code{username}) +#' @param password your password +#' @param auth_token To install from a private repo, generate a personal +#' access token (PAT) in \url{https://github.com/settings/applications} and +#' supply to this argument. This is safer than using a password because +#' you can easily delete a PAT without affecting any others. Defaults to +#' the \code{GITHUB_PAT} environment variable. +#' @param github_url Defaults to NULL, so the default archive URL is served +#' from the GitHub API. You can set it to your custom Enterprise GitHub URL. +#' @param ... Other arguments passed on to \code{\link{install}}. +#' @param dependencies By default, installs all dependencies so that you can +#' build vignettes and use all functionality of the package. #' @export #' @family package installation #' @examples diff --git a/man/install_github_enterprise.Rd b/man/install_github_enterprise.Rd index a44f98939..e07bdce01 100644 --- a/man/install_github_enterprise.Rd +++ b/man/install_github_enterprise.Rd @@ -8,6 +8,46 @@ install_github_enterprise(repo, username = getOption("github.user"), auth_user = NULL, password = NULL, auth_token = github_pat(), github_url = devtools_git_enterprise(), ..., dependencies = TRUE) } +\arguments{ +\item{repo}{Repository address in the format +\code{[username/]repo[/subdir][@ref|#pull]}. Alternatively, you can +specify \code{username}, \code{subdir}, \code{ref} or \code{pull} using the +respective parameters (see below); if both is specified, the values in +\code{repo} take precedence.} + +\item{username}{User name} + +\item{ref}{Desired git reference. Could be a commit, tag, or branch +name. Defaults to \code{"master"}.} + +\item{pull}{Desired pull request. A pull request refers to a branch, +so you can't specify both \code{branch} and \code{pull}; one of +them must be \code{NULL}.} + +\item{subdir}{subdirectory within repo that contains the R package.} + +\item{branch}{Deprecated. Use \code{ref} instead.} + +\item{auth_user}{your account username if you're attempting to install +a package hosted in a private repository (and your username is different +to \code{username})} + +\item{password}{your password} + +\item{auth_token}{To install from a private repo, generate a personal +access token (PAT) in \url{https://github.com/settings/applications} and +supply to this argument. This is safer than using a password because +you can easily delete a PAT without affecting any others. Defaults to +the \code{GITHUB_PAT} environment variable.} + +\item{github_url}{Defaults to NULL, so the default archive URL is served +from the GitHub API. You can set it to your custom Enterprise GitHub URL.} + +\item{...}{Other arguments passed on to \code{\link{install}}.} + +\item{dependencies}{By default, installs all dependencies so that you can +build vignettes and use all functionality of the package.} +} \description{ This function allows you to install a package built with \code{devtools} from a repo with a custom URL. From aba1e878aafb70ba7f6a6c143afcd8a8ab7054cc Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Mon, 30 Jun 2014 18:05:46 -0700 Subject: [PATCH 10/17] Rebuild docs for install_github[_enterprise]() --- man/install_github.Rd | 8 +------- man/install_github_enterprise.Rd | 12 +++--------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/man/install_github.Rd b/man/install_github.Rd index fe715894f..501351438 100644 --- a/man/install_github.Rd +++ b/man/install_github.Rd @@ -4,14 +4,8 @@ \title{Attempts to install a package directly from github.} \usage{ install_github(repo, username = getOption("github.user"), ref = "master", -<<<<<<< HEAD - pull = NULL, subdir = NULL, branch = NULL, auth_user = NULL, - password = NULL, auth_token = github_pat(), github_url = NULL, ..., - dependencies = TRUE) -======= subdir = NULL, auth_user = NULL, password = NULL, - auth_token = github_pat(), ..., dependencies = TRUE) ->>>>>>> upstream/master + auth_token = github_pat(), github_url = NULL, ..., dependencies = TRUE) } \arguments{ \item{repo}{Repository address in the format diff --git a/man/install_github_enterprise.Rd b/man/install_github_enterprise.Rd index e07bdce01..88f96ca12 100644 --- a/man/install_github_enterprise.Rd +++ b/man/install_github_enterprise.Rd @@ -4,9 +4,9 @@ \title{Convenience wrapper for \code{\link{install_github}}.} \usage{ install_github_enterprise(repo, username = getOption("github.user"), - ref = "master", pull = NULL, subdir = NULL, branch = NULL, - auth_user = NULL, password = NULL, auth_token = github_pat(), - github_url = devtools_git_enterprise(), ..., dependencies = TRUE) + ref = "master", subdir = NULL, auth_user = NULL, password = NULL, + auth_token = github_pat(), github_url = devtools_git_enterprise(), ..., + dependencies = TRUE) } \arguments{ \item{repo}{Repository address in the format @@ -20,14 +20,8 @@ respective parameters (see below); if both is specified, the values in \item{ref}{Desired git reference. Could be a commit, tag, or branch name. Defaults to \code{"master"}.} -\item{pull}{Desired pull request. A pull request refers to a branch, -so you can't specify both \code{branch} and \code{pull}; one of -them must be \code{NULL}.} - \item{subdir}{subdirectory within repo that contains the R package.} -\item{branch}{Deprecated. Use \code{ref} instead.} - \item{auth_user}{your account username if you're attempting to install a package hosted in a private repository (and your username is different to \code{username})} From 212361398e8b3594e7e4b419e547a173daeb6aae Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Mon, 30 Jun 2014 18:54:21 -0700 Subject: [PATCH 11/17] Fixed the install_url() call --- R/install-github.r | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/R/install-github.r b/R/install-github.r index 638d2cf20..b335be4f6 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -171,7 +171,7 @@ github_get_conn <- function(repo, username = getOption("github.user"), param$username, param$repo, "zipball", param$ref, sep = "/") } else { - param$url <- paste(github_url, "/", param$username, + param$url <- paste(github_url, param$username, "/", param$repo,"/archive/", param$ref, ".zip", sep = "") } @@ -220,13 +220,18 @@ install_github_single <- function(repo, username = getOption("github.user"), # Don't record password for security reasons #append_field("Password", conn$password) } - - # The downloaded file is always named by the package's name with extension .zip. - # install_github("shiny", "rstudio", "v/0/2/1") - # URL: https://api.github.com/repos/rstudio/shiny/zipball/v/0/2/1 - # Output file: shiny.zip - install_url(conn$url, name = paste(conn$repo, ".zip", sep = ""), subdir = conn$subdir, - config = conn$auth, before_install = github_before_install, ...) + + if(is.null(github_url)) { + # The downloaded file is always named by the package's name with extension .zip. + # install_github("shiny", "rstudio", "v/0/2/1") + # URL: https://api.github.com/repos/rstudio/shiny/zipball/v/0/2/1 + # Output file: shiny.zip + install_url(conn$url, name = paste(conn$repo, ".zip", sep = ""), subdir = conn$subdir, + config = conn$auth, before_install = github_before_install, ...) + } else { + # Go with custom URL scheme + install_url(conn$url, config = conn$auth) + } } #' Resolve a token to a GitHub reference From 600ffcd7daaa4766ba134df6e5adf961a8834e5b Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 2 Jul 2014 19:47:01 -0700 Subject: [PATCH 12/17] Fixed has_devel.r to match change by @krlmlr --- R/has-devel.r | 2 +- man/install_svn.Rd | 30 ++++++++++++++---------------- man/install_svn_single.Rd | 25 ++++++++++++------------- man/svn-path.Rd | 13 ------------- 4 files changed, 27 insertions(+), 43 deletions(-) delete mode 100644 man/svn-path.Rd diff --git a/R/has-devel.r b/R/has-devel.r index 3f8d38740..e741912d7 100644 --- a/R/has-devel.r +++ b/R/has-devel.r @@ -26,7 +26,7 @@ has_devel <- function() { check_build_tools <- function(pkg = ".") { pkg <- as.package(pkg) - if (!file.exists(pkg$path, "src")) return(TRUE) + if (!file.exists(file.path(pkg$path, "src"))) return(TRUE) check <- getOption("buildtools.check", NULL) if (!is.null(check)) { diff --git a/man/install_svn.Rd b/man/install_svn.Rd index 7389a4fed..254b35cf9 100644 --- a/man/install_svn.Rd +++ b/man/install_svn.Rd @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.1): do not edit by hand \name{install_svn} \alias{install_svn} \title{Install a package from a SVN repository} @@ -6,28 +7,24 @@ install_svn(svn_url, name = NULL, subdir = "trunk", branch = NULL, svn_args = character(0), svn_binary = NULL, ...) } \arguments{ - \item{branch}{Name of branch or tag to use, if not - trunk.} +\item{branch}{Name of branch or tag to use, if not trunk.} - \item{...}{Other arguments passed on to - \code{\link{install}}} +\item{...}{Other arguments passed on to \code{\link{install}}} - \item{svn_url}{Location of package. The url should point - to a public or private repository.} +\item{svn_url}{Location of package. The url should point to a public or +private repository.} - \item{name}{Optional package name, used to provide more - informative messages.} +\item{name}{Optional package name, used to provide more informative +messages.} - \item{subdir}{A sub-directory withing a svn repository - that may contain the package we are interested in - installing. By default, this points to the 'trunk' - directory.} +\item{subdir}{A sub-directory withing a svn repository that may contain the +package we are interested in installing. By default, this +points to the 'trunk' directory.} - \item{svn_args}{A character vector providing extra - arguments to pass on to} +\item{svn_args}{A character vector providing extra arguments to pass on to} - \item{svn_binary}{A custom svn-binary to use instead of - default system's svn version.} +\item{svn_binary}{A custom svn-binary to use instead of default system's svn +version.} } \description{ This function requires \code{svn} to be installed on your system in order to @@ -46,6 +43,7 @@ install_svn(c("https://github.com/hadley/devtools", "https://github.com/hadley/s } \seealso{ Other package installation: \code{\link{install_bitbucket}}; + \code{\link{install_github_enterprise}}; \code{\link{install_github}}; \code{\link{install_gitorious}}; \code{\link{install_git}}; \code{\link{install_url}}; diff --git a/man/install_svn_single.Rd b/man/install_svn_single.Rd index aee445fe8..a56688064 100644 --- a/man/install_svn_single.Rd +++ b/man/install_svn_single.Rd @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.1): do not edit by hand \name{install_svn_single} \alias{install_svn_single} \title{Install a single package from a svn repository} @@ -6,24 +7,22 @@ install_svn_single(svn_url, name = NULL, subdir = "trunk", branch = NULL, svn_args = character(), svn_binary = NULL, ...) } \arguments{ - \item{svn_url}{Location of package. The url should point - to a public or private repository.} +\item{svn_url}{Location of package. The url should point to a public or +private repository.} - \item{name}{Optional package name, used to provide more - informative messages.} +\item{name}{Optional package name, used to provide more informative +messages.} - \item{subdir}{A sub-directory withing a svn repository - that may contain the package we are interested in - installing. By default, this points to the 'trunk' - directory.} +\item{subdir}{A sub-directory withing a svn repository that may contain the +package we are interested in installing. By default, this +points to the 'trunk' directory.} - \item{svn_args}{A character vector providing extra - arguments to pass on to} +\item{svn_args}{A character vector providing extra arguments to pass on to} - \item{svn_binary}{A custom svn-binary to use instead of - default system's svn version.} +\item{svn_binary}{A custom svn-binary to use instead of default system's svn +version.} - \item{...}{passed on to \code{\link{install}}} +\item{...}{passed on to \code{\link{install}}} } \description{ This function allows you to install a single package from a svn repository. diff --git a/man/svn-path.Rd b/man/svn-path.Rd deleted file mode 100644 index d1ac5960c..000000000 --- a/man/svn-path.Rd +++ /dev/null @@ -1,13 +0,0 @@ -\name{svn_path} -\alias{svn_path} -\title{Retrieve the current running path of the svn binary.} -\usage{ -svn_path(svn_binary_name = NULL) -} -\arguments{ - \item{svn_binary_name}{The name of the binary depending - on the OS.} -} -\description{ -Retrieve the current running path of the svn binary. -} From 2f99c35b0a9da5072f0851f3c6d60c944961e765 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Wed, 16 Jul 2014 11:05:25 -0700 Subject: [PATCH 13/17] Set github_url to API v3 redirect Doesn't work yet. Old-school archive/master.zip redirect still does. --- R/install-github.r | 17 +++++++++++++---- man/install_github_enterprise.Rd | 4 +++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/R/install-github.r b/R/install-github.r index b335be4f6..aa62f3527 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -85,7 +85,9 @@ install_github <- function(repo, username = getOption("github.user"), #' you can easily delete a PAT without affecting any others. Defaults to #' the \code{GITHUB_PAT} environment variable. #' @param github_url Defaults to NULL, so the default archive URL is served -#' from the GitHub API. You can set it to your custom Enterprise GitHub URL. +#' from the GitHub API. You can set it to your custom Enterprise GitHub URL, +#' but it must point to your own implementation of the archive link server +#' API all the way -- e.g. \code{https://github.yourcompany.com/api/v3/repos} #' @param ... Other arguments passed on to \code{\link{install}}. #' @param dependencies By default, installs all dependencies so that you can #' build vignettes and use all functionality of the package. @@ -171,9 +173,16 @@ github_get_conn <- function(repo, username = getOption("github.user"), param$username, param$repo, "zipball", param$ref, sep = "/") } else { - param$url <- paste(github_url, param$username, "/", - param$repo,"/archive/", - param$ref, ".zip", sep = "") + # GitHub API v3 version + param$url <- paste(paste(github_url, "api/v3/repos", + param$username, param$repo, "legacy.zip", + param$ref, param$repo, sep = "/"), + "zip", sep = ".") + # old-school archive/master.zip version + param$url <- paste(paste(github_url, param$username, + param$repo, "archive", + param$ref, sep="/"), + "zip", sep = ".") } param } diff --git a/man/install_github_enterprise.Rd b/man/install_github_enterprise.Rd index 88f96ca12..571db77a2 100644 --- a/man/install_github_enterprise.Rd +++ b/man/install_github_enterprise.Rd @@ -35,7 +35,9 @@ you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} \item{github_url}{Defaults to NULL, so the default archive URL is served -from the GitHub API. You can set it to your custom Enterprise GitHub URL.} +from the GitHub API. You can set it to your custom Enterprise GitHub URL, +but it must point to your own implementation of the archive link server +API all the way -- e.g. \code{https://github.yourcompany.com/api/v3/repos}} \item{...}{Other arguments passed on to \code{\link{install}}.} From 60343ce1c249382102e572e6fd7f4147640f9224 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Fri, 15 Aug 2014 16:03:37 -0700 Subject: [PATCH 14/17] Less typing, right URL --- R/install-github.r | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/R/install-github.r b/R/install-github.r index 29d0ac1c2..c4ae44b08 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -151,15 +151,13 @@ github_get_conn <- function(repo, username = NULL, "from", paste(username, collapse = ", ")) - if(is.null(github_url)) { - param$url <- paste("https://api.github.com", "repos", - param$username, param$repo, - "zipball", param$ref, sep = "/") - } else { - param$url <- paste(github_url, "api/v3/repos", - param$username, param$repo, "legacy.zip", - param$ref, sep = "/") - } + url <- paste("https://api.github.com", "repos",sep="/") + # If github_url is given, a private repo is assumed. + if(!is.null(github_url)) { + url <- paste(github_url,"api/v3/repos",sep="/") + } + param$url <- paste(url, param$username, param$repo, + "zipball", param$ref, sep = "/") param } From 9f8bbac5c27fde7afaaae3337ea70b7fc6ff3cb6 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Tue, 19 Aug 2014 11:41:33 -0400 Subject: [PATCH 15/17] Fixed url param in github_ref.github_pull() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The list element param$github_url does not exist so it’s always NULL. The function should check instead the element param$url, which may or may not be NULL. --- R/install-github.r | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/install-github.r b/R/install-github.r index c4ae44b08..07a6a1ba0 100644 --- a/R/install-github.r +++ b/R/install-github.r @@ -67,9 +67,10 @@ install_github <- function(repo, username = NULL, #' specify \code{username}, \code{subdir}, \code{ref} or \code{pull} using the #' respective parameters (see below); if both is specified, the values in #' \code{repo} take precedence. -#' @param username User name +#' @param username User name. Deprecate: please include username in the +#' \code{repo} #' @param ref Desired git reference. Could be a commit, tag, or branch -#' name. Defaults to \code{"master"}. +#' name, or a call to \code{\link{github_pull}}. Defaults to \code{"master"}. #' @param subdir subdirectory within repo that contains the R package. #' @param auth_token To install from a private repo, generate a personal #' access token (PAT) in \url{https://github.com/settings/applications} and @@ -77,9 +78,7 @@ install_github <- function(repo, username = NULL, #' you can easily delete a PAT without affecting any others. Defaults to #' the \code{GITHUB_PAT} environment variable. #' @param github_url Defaults to NULL, so the default archive URL is served -#' from the GitHub API. You can set it to your custom Enterprise GitHub URL, -#' but it must point to your own implementation of the archive link server -#' API all the way -- e.g. \code{https://github.yourcompany.com/api/v3/repos} +#' from the GitHub API. You can set it to your custom Enterprise GitHub URL. #' @param ... Other arguments passed on to \code{\link{install}}. #' @param dependencies By default, installs all dependencies so that you can #' build vignettes and use all functionality of the package. @@ -231,8 +230,8 @@ github_ref.github_pull <- function(x, param) { host <- "https://api.github.com" # resolve to custom URL if set - if(!is.null(param$github_url)) { - host <- paste(param$github_url,"api/v3",sep="/") + if(!is.null(param$url)) { + host <- paste(param$url,"api/v3",sep="/") } # GET /repos/:user/:repo/pulls/:number path <- paste("repos", param$username, param$repo, "pulls", x, sep = "/") @@ -279,6 +278,7 @@ github_parse_path <- function(path) { github_rx <- sprintf("^(?:%s%s%s%s|(.*))$", username_rx, repo_rx, subdir_rx, ref_or_pull_rx) + param_names <- c("username", "repo", "subdir", "ref", "pull", "invalid") replace <- setNames(sprintf("\\%d", seq_along(param_names)), param_names) params <- lapply(replace, function(r) gsub(github_rx, r, path, perl = TRUE)) From 3f027659441183014be2dcbc4c6a4e5ece65788e Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Thu, 21 Aug 2014 10:07:23 -0700 Subject: [PATCH 16/17] Quick fix --- R/decompress.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/decompress.r b/R/decompress.r index 98b7123f9..bb53495a8 100644 --- a/R/decompress.r +++ b/R/decompress.r @@ -40,7 +40,7 @@ getrootdir <- function(file_list) { my_unzip <- function(src, target, unzip = getOption("unzip")) { if (unzip == "internal") { - unzip(src, exdir = target) + return(unzip(src, exdir = target)) } args <- paste( From 2e64563b551b9d0488fdfd87051da00995e64676 Mon Sep 17 00:00:00 2001 From: Gabi Huiber Date: Thu, 21 Aug 2014 10:32:24 -0700 Subject: [PATCH 17/17] New Rd file for install_github_enterprise() --- man/install_github_enterprise.Rd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/man/install_github_enterprise.Rd b/man/install_github_enterprise.Rd index c981acf99..86d94a54a 100644 --- a/man/install_github_enterprise.Rd +++ b/man/install_github_enterprise.Rd @@ -14,10 +14,11 @@ specify \code{username}, \code{subdir}, \code{ref} or \code{pull} using the respective parameters (see below); if both is specified, the values in \code{repo} take precedence.} -\item{username}{User name} +\item{username}{User name. Deprecate: please include username in the +\code{repo}} \item{ref}{Desired git reference. Could be a commit, tag, or branch -name. Defaults to \code{"master"}.} +name, or a call to \code{\link{github_pull}}. Defaults to \code{"master"}.} \item{subdir}{subdirectory within repo that contains the R package.} @@ -28,9 +29,7 @@ you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} \item{github_url}{Defaults to NULL, so the default archive URL is served -from the GitHub API. You can set it to your custom Enterprise GitHub URL, -but it must point to your own implementation of the archive link server -API all the way -- e.g. \code{https://github.yourcompany.com/api/v3/repos}} +from the GitHub API. You can set it to your custom Enterprise GitHub URL.} \item{...}{Other arguments passed on to \code{\link{install}}.}