-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add SHA updating logic for github remotes #135
Conversation
R/github.R
Outdated
tmp <- tempfile() | ||
download(tmp, url, auth_token = github_pat()) | ||
|
||
rawToChar(base64enc::base64decode(gsub("\\\\n", "", fromJSONFile(tmp)$content))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the current blocker for this, we need to decode the base64 encoded content, so I guess would have to write a R only version of base64decode()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: now have this
Yeah!! 🎉 🎉 🎉 |
2170efa
to
23f86b2
Compare
Codecov Report
@@ Coverage Diff @@
## master #135 +/- ##
=========================================
Coverage ? 82.02%
=========================================
Files ? 27
Lines ? 1524
Branches ? 0
=========================================
Hits ? 1250
Misses ? 274
Partials ? 0
Continue to review full report at Codecov.
|
2d551e7
to
fb58c49
Compare
@gaborcsardi I realize this is probably too big now to review in detail; do you have any overall comments and would you be ok with me merging this and working on the open issues? |
Ill take a look later today.
…On Mon, 6 Aug 2018, 16:38 Jim Hester, ***@***.***> wrote:
@gaborcsardi <https://github.com/gaborcsardi> I realize this is probably
too big now to review in detail; do you have any overall comments and would
you be ok with me merging this and working on the open issues?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#135 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAoTQC1yHD6tgCX3yfh1RNyAVpRjzMNaks5uOFTZgaJpZM4Voe2D>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super cool! Left some minor comments. Thanks for doing this.
R/deps.R
Outdated
} | ||
fun <- tryCatch(get(paste0(tolower(type), "_remote"), | ||
envir = asNamespace("remotes"), mode = "function", inherits = FALSE), | ||
error = function(e) stop("Unknown remote type: ", type, call. = FALSE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK, this will find things like parse_one_remote()
, etc. Not that this happens in practice, but it does not seem right to me. How about just create an object, try to dispatch, and then fail, if the dispatch fails.
R/install-git.R
Outdated
#'} | ||
install_git <- function(url, subdir = NULL, branch = NULL, | ||
install_git <- function(url, subdir = NULL, ref = NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. Can we re-add a branch
argument and forward that to ref
? If you think it is worth it. Only in the user facing function.
on.exit(unlink(tmp)) | ||
description_path <- paste0(collapse = "/", c(remote$subdir, "DESCRIPTION")) | ||
|
||
# Try using git archive --remote to retrieve the DESCRIPTION, if the protocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this means that even for git2r remotes we need a command line git? So can't we just use that for everything and remove the git2r stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need command line git to get the remote package name, but if you can't get it because command line git is not available the thing we then just install the remote unconditionally. So it will still work without command line git, just won't be as efficient as it could be.
I think it is still useful to have both types of remotes, although I agree it does increase the complexity considerably; the code is already written...
R/install-git.R
Outdated
res <- try(silent = TRUE, | ||
system_check(git_path(), | ||
args = c("archive", "-o", tmp, "--remote", remote$url, | ||
if (is.null(remote$ref)) "HEAD" else remote$ref, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sometimes HEAD
, sometimes master
(see below). Which one is right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably HEAD
as it is most generic
R/install-gitlab.R
Outdated
@@ -0,0 +1,138 @@ | |||
#' Instlal a package from GitLab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
local_sha <- local_sha(remote_package_name(remote)) | ||
} | ||
|
||
same <- remote_sha == local_sha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always have a full sha here? (As opposed to the first 7 characters or sg like that?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, IIRC all of the methods return the full untruncated sha.
R/install-remote.R
Outdated
package2remote(name)$sha %||% NA_character_ | ||
} | ||
|
||
package2remote <- function(name, lib = .libPaths(), repos = getOption("repos"), type = getOption("pkgType")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an important internal function. Do you think you could add some brief (internal) docs that explain what it is used for? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I wonder if it would be useful to export this actually, it can sometimes be handy, e.g. if you want to re-install a package from another library. Although this would also require exporting install_remote()
.
R/install-remote.R
Outdated
} | ||
|
||
#' @export | ||
`[.remotes` <- function(x,i,...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this trick needed? Can you please add it as internal docs, or a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible it is not needed, I will remove it and see if anything breaks.
It was not installed, so coverage was not running on travis previously
This avoids a breaking change
This reverts commit 2d4c782.
This seems to be due to a regression in roxygen 6.1.0
Mainly to avoid duplicating the protocol if it exists
This is about ~4 times faster than without because we can return just the SHA by passing the appropriate header bench::mark(iterations=30, curl = github_commit("r-lib", "devtools", host = "api.github.com", use_curl = TRUE), base = github_commit("r-lib", "devtools", host = "api.github.com", use_curl = FALSE)) # A tibble: 2 x 14 expression min mean median max `itr/sec` <chr> <bch:tm> <bch:tm> <bch:tm> <bch:tm> <dbl> 1 curl 68.6ms 84.2ms 81.4ms 164ms 11.9 2 base 261.8ms 316.4ms 284.9ms 615ms 3.16
This was missing in the remote dependencies, which caused rbind's to fail
It has changed in R-devel
61fe315
to
d82007f
Compare
Thank you for the review Gabor, I appreciated the comments! |
This updates remotes with the logic from the current devel devtools (only for the github remote).
Since pkgman and friends seem to be a ways off it might be worth trying to update remotes further and use that on travis / appveyor etc. The process was somewhat easier than I expected originally.