Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Gitlab auth_token to packages listed in Remotes #266

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions R/deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@

package_deps <- function(packages, dependencies = NA,
repos = getOption("repos"),
type = getOption("pkgType")) {
type = getOption("pkgType"),
...) {

repos <- fix_repositories(repos)
cran <- available_packages(repos, type)
Expand All @@ -69,7 +70,7 @@ package_deps <- function(packages, dependencies = NA,
remote <- structure(lapply(deps, package2remote, repos = repos, type = type), class = "remotes")

inst_ver <- vapply(deps, local_sha, character(1))
cran_ver <- vapply(remote, function(x) remote_sha(x), character(1))
cran_ver <- vapply(remote, function(x) remote_sha(x, ...), character(1))
is_cran_remote <- vapply(remote, inherits, logical(1), "cran_remote")

diff <- compare_versions(inst_ver, cran_ver, is_cran_remote)
Expand Down Expand Up @@ -134,7 +135,7 @@ dev_package_deps <- function(pkgdir = ".", dependencies = NA,
}

combine_deps(
package_deps(deps, repos = repos, type = type),
package_deps(deps, repos = repos, type = type, ...),
remote_deps(pkg, ...))
}

Expand Down Expand Up @@ -510,7 +511,7 @@ remote_deps <- function(pkg, ...) {

package <- vapply(remote, function(x) remote_package_name(x), character(1), USE.NAMES = FALSE)
installed <- vapply(package, function(x) local_sha(x), character(1), USE.NAMES = FALSE)
available <- vapply(remote, function(x) remote_sha(x), character(1), USE.NAMES = FALSE)
available <- vapply(remote, function(x) remote_sha(x, ...), character(1), USE.NAMES = FALSE)
diff <- installed == available
diff <- ifelse(!is.na(diff) & diff, CURRENT, BEHIND)
diff[is.na(installed)] <- UNINSTALLED
Expand Down
4 changes: 4 additions & 0 deletions R/install-gitlab.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ remote_package_name.gitlab_remote <- function(remote, ...) {

#' @export
remote_sha.gitlab_remote <- function(remote, ...) {
if (is.null(remote$auth_token)) {
auth_token <- list(...)
remote$auth_token <- auth_token$auth_token
}
gitlab_commit(username = remote$username, repo = remote$repo,
host = remote$host, ref = remote$ref, pat = remote$auth_token)
}
Expand Down
4 changes: 2 additions & 2 deletions R/install-remote.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install_remote <- function(remote,

package_name <- remote_package_name(remote)
local_sha <- local_sha(package_name)
remote_sha <- remote_sha(remote, local_sha)
remote_sha <- remote_sha(remote, local_sha, ...)

if (!isTRUE(force) &&
!different_sha(remote_sha = remote_sha, local_sha = local_sha)) {
Expand Down Expand Up @@ -142,7 +142,7 @@ local_sha <- function(name) {
# is added to the package when it is installed by remotes. If the package is
# installed some other way, such as by `install.packages()` there will be no
# meta-data, so there we construct a generic CRAN remote.
package2remote <- function(name, lib = .libPaths(), repos = getOption("repos"), type = getOption("pkgType")) {
package2remote <- function(name, lib = .libPaths(), repos = getOption("repos"), type = getOption("pkgType"), ...) {

x <- tryCatch(utils::packageDescription(name, lib.loc = lib), error = function(e) NA, warning = function(e) NA)

Expand Down
6 changes: 3 additions & 3 deletions man/package_deps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.