-
Notifications
You must be signed in to change notification settings - Fork 761
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
Install sha (second attempt) #1027
Conversation
Here's an alternative plan that might make things simpler. How about instead of having That removes the whole chicken and the egg issue and we can just write a function for |
See proof on concept jimhester@aa15cd0 which works with limited testing on my machine. |
Also note this is using |
OK, I like this idea, but have some questions:
I'm willing to implement and properly test your suggestion, but just wanted to bring these up. |
The idea would be to change the other
|
OK, I like that idea even better. Final point, add to this pull request, or start over and submit a new one? |
Sorry I was not more clear in my proof on concept what I had in mind. I would keep this pull request. Actually I would have kept the previous one open so that the discussion was all together, you can always # reset state to previous state
git reset upstream/master
# make new commits
...
git push --force To remove the old commits if needed. |
So currently, the
Does that seem reasonable? I'll start actually coding something up. |
I would really follow my proof on concept. Just write a new method for remote_metadata.package <- function(x, bundle = NULL, source = NULL) {
list(
RemoteType = "package",
RemoteUrl = x$path,
RemoteSha = if (git_committed(x$path)) git_sha1(path = x$path)
)
} Make the default argument for install if (length(metadata)) {
add_metadata(base::system.file(package = pkg$package), metadata)
} Then just change https://github.com/hadley/devtools/blob/master/R/install-remote.R#L20-L25 to pass the metadata to diff --git a/R/install-remote.R b/R/install-remote.R
index b1192b4..a22232a 100644
--- a/R/install-remote.R
+++ b/R/install-remote.R
@@ -17,12 +17,13 @@ install_remote <- function(remote, ..., quiet = FALSE) {
source <- source_pkg(bundle, subdir = remote$subdir)
on.exit(unlink(source, recursive = TRUE), add = TRUE)
- add_metadata(source, remote_metadata(remote, bundle, source))
-
# Because we've modified DESCRIPTION, its original MD5 value is wrong
clear_description_md5(source)
- install(source, ..., quiet = quiet)
+ install(source,
+ metadata = remote_metadata(remote, bundle, source),
+ ..., quiet = quiet)
+
} You actually don't have to change any of the |
jimhester@212d272 has a working implementation passing the regular devtools tests (https://travis-ci.org/rmflight/devtools/builds/102617084#L2277-L2279). It just needs documentation and some additional tests written if possible. |
OK, trying it out, and there is an issue. |
I've got an implementation, but the test indicates that it doesn't work at modifying the information that shows up in |
As I noted, 70b9b25#diff-17d36a2a2b0eac6b55b22dae5787dc48R167, this test fails because Do you or @hadley know offhand if there is a function for writing RDS files outside of what INSTALL does? |
just found it, looks like |
I also think I might need to create some tests just for |
Mmm yes that is an issue, see jimhester@bd0cff1 for code which updates it as well as the |
OK, this works (rmflight/devtools@9c7447a961), and passes all of the previous |
@@ -46,3 +46,13 @@ remote_metadata.local_remote <- function(x, bundle = NULL, source = NULL) { | |||
RemoteSha = if (uses_git(x$path)) git_sha1(path = x$path) | |||
) | |||
} | |||
|
|||
#' @export | |||
remote_metadata.package <- function(x, bundle = NULL, source = 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.
If we change this to the following it will give us consistent results with the legacy behavior if the package is not using git or has an unclean working directory.
compact(list(
RemoteType = "local",
RemoteUrl = x$path,
RemoteSubdir = x$subdir,
RemoteSha = if (git_committed(x$path)) git_sha1(path = x$path)
))
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.
Actually I am wrong, just looked at the code for pkg_source
https://github.com/hadley/devtools/blob/81dd313e1d143a3bdaaa2e1f09c887801db66694/R/session-info.r#L156-L159
Ok this is looking good, I think we should modify https://github.com/hadley/devtools/blob/81dd313e1d143a3bdaaa2e1f09c887801db66694/R/session-info.r#L156-L159 to work with this situation better. Right now the code assumes there is always a |
In for a penny, in for a pound. May as well make it consistent somewhere else. |
It would be super useful if you could also fill in the github info if the repo has been pushed to github. (That would make my life easier when working with shinyapps and development versions of my packages) |
That sounds really useful and cool @hadley, but can we maybe make an issue and assign it to me, and I can work on that particular feature some other time? I want to get the reporting in |
ok, rmflight/devtools@bb9e337 has a modified from github: from local git with clean tree and and then local git with a dirty working directory: does that work for you @jimhester ? |
This should fill in the github user/repo information if the repository has a github remote set up. It doesn't necessarily mean the given revision is actually pushed to that remote however... diff --git a/R/install-local.r b/R/install-local.r
index 6877f5d..b7d843e 100644
--- a/R/install-local.r
+++ b/R/install-local.r
@@ -49,10 +49,18 @@ remote_metadata.local_remote <- function(x, bundle = NULL, source = NULL) {
#' @export
remote_metadata.package <- function(x, bundle = NULL, source = NULL) {
- list(
- RemoteType = "package",
- RemoteUrl = x$path,
- RemoteSubdir = x$subdir,
- RemoteSha = if (git_committed(x$path)) git_sha1(path = x$path)
+ res <- list(
+ RemoteType = "local",
+ RemoteUrl = x$path
)
+
+ if (git_committed(x$path)) {
+ res$RemoteSha <- git_sha1(path = x$path)
+ }
+ if (uses_github(x$path)) {
+ info <- github_info(x$path)
+ res$RemoteUsername <- info$username
+ res$RemoteRepo <- info$repo
+ }
+ res
} |
Also I am not sure having a |
OK, fair enough on the If changing this, I feel like |
If the two functions are literally the same I think we should just make them aliases. remote_metadata.package <- remote_metadata.local_remote Also could you rebase this on the current master and possibly squash some of the more trivial commits. https://help.github.com/articles/about-git-rebase/ has some help on using Git rebase if you need a reference. |
OK. Originally went with two functions so it would be easier to change in the future if decided they should be different, but you are right, currently they are the same, so should just alias one from the other. I will give rebasing an attempt, this is the first time I've tried to use it. |
Just remember you can always abort the rebase with
|
Thanks, that helps. |
…les that are no longer needed
…wo if statements instead of an if else if
…he setting to NULL in else statements to make it a little clearer
I don't think the logic is quite right. When I run |
The problem is that |
Is there an easy way to tell that it was done by load_all so as to avoid On Wed, Jan 20, 2016, 5:56 PM Hadley Wickham [email protected]
|
@rmflight Best thing to do is just use |
…version of the package, and add a test using load_all() followed by install as this was causing a failure previously
Used inst() in 1c3fccd, and added a test of |
Ok - this now just needs a bullet in NEWS.md and we're good to merge. @jjallaire @kevinushey FYI: this PR will add git/github information when installing from a local package. I vaguely remember there's some interaction with packrat, so you need to know about this. |
…emote-metadata testing
@jimhester: using |
…gument and the change in behavior.
OK, I'm curious, how do I resolve a conflict that I can't see? |
Don't worry about it, I just merged by hand. |
Thank you! And thank you and @jimhester for all of your support and coaching through this process. Just so you know, this was my first pull request that involved any amount of real code, and you both made it a pretty cool experience. |
@jimhester, based on our earlier conversations, here is a second attempt at adding the SHA1 to the package install. It uses
git_committed
as we discussed as the default function ofadd_sha
, and then if that passes, will then useinstall_local
to copy the package to a temp directory and do the install from there, which automatically adds the SHA1.Note that the call to
install_local
probably needs to have all the otherinstall
arguments added to it to truly work as intended, but this currently passes all the tests, including the ones I added.If this passes muster, I will add the rest of the install arguments to the
install_local
call.The only ugly part of this I don't like is the
return()
statement that keeps a second round ofinstall
from happening and installing the one in the current directory, because that causes aNULL
return value. I don't know how to avoid that ATM.