-
Notifications
You must be signed in to change notification settings - Fork 33
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
Avoid failing to install git remotes when packfile parsing fails for unnecessary files #355
Conversation
Thanks! Do you have some example repos we can use for testing? |
I do, but it's a private enterprise repo that I was using for testing. I only manually tested the case where it should succeed, but don't have a counter-example that should still emit a warning/error. I don't mind setting them up, but I think it be easier to maintain if the testing repos were also under If that sounds reasonable to you, I can kick off some repos. I would make two with the following structures: Negative Test CaseShould fail to install, as necessary submodule will not be parsed out of the packfile Update: repo created
Positive Test CaseShould successfully install as submodules are either outside the package subdir, or excluded via Update: repo created
|
#' Rebuild fixtures | ||
#' | ||
#' @examples | ||
#' testthat::test_dir(testthat::test_path("fixtures")) | ||
#' |
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.
I added a "test" file in the tests/testthat/fixtures
directory to rebuild the relevant packfiles. Happy to retool this if you have a different style in mind, I just wanted to make sure the process for generating some testing fixtures was reproducible.
throw(pkg_error( | ||
"{sum(!files)} necessary file{?s} {?was/were} unable to be fetched", | ||
paste0("'", names(files)[!files], "'", collapse = ", "), | ||
.class = "pkgdepends_git_fetch" | ||
)) |
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.
In the initial PR this was originally a warning, but if files are required for properly building the package I felt it should probably be an error.
Ideally we could emit a warning and let R continue and fail when it tries to build the package, but R doesn't have any way to know that the files are missing so it would just happily build a faulty package. I think this would be a worse failure mode so I converted it to an error.
@dgkf I have implemented git submodules now. Is there any other reason for files to be missing? |
🎉 🎉 Sounds great! Thanks for investing what it would take to implement submodules back when I started this and it is no small task, so thank you for taking that on!
Submodules are the only use case I'm aware of. I just left it ambiguous since it would work in other situations as well. From what I can tell, your submodules implementation should address these needs as well, so feel free to close. |
Following on the comment in #354 (comment), this records a listing of paths in a git remote that failed to be parsed out of the packfile. Notably, this will allow for gracefully recovering from failing to clone submodules in cases where they are not required for the package to build, though it would apply in other instances as well.
Instead of failing immediately, this gives the opportunity to determine the severity of failing to parse the file tree out of the packfile and only throw an error if a file is necessary for the package to build.
This also implements a check for severity, disregarding files outside a remote subdir if one is provided, or files ignored in
.Rbuildignore
.