-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
When --offline flag specified for forc build, attempt to use local git checkouts for git dependencies before failing #2366
Conversation
…os_with_branch, introduced with_search_checkouts
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.
Nice one @kayagokalp! Just had a quick first review as I've been pushing back reviewing this for too long :)
Converting this into draft until we are done with |
Pull request was converted to draft
Quick update on my status :) @mitchmindtree, so as we discussed briefly yesterday, just storing
|
After a quick discussion over slack with @mitchmindtree, decided to go different path. I guess this is ready for a review 👍 Quick summary of what is happening here:
Since Only possible problem might be with a I tried to run 16 concurrent My Testing Procedure:
After these steps you will have both master and latest tag checkouts in your local.
|
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.
Awesome stuff @kayagokalp, this is looking great! Just a few nits then happy to approve 👍
I believe this can also happen before this PR too, because the checkout is done after everything is removed and there is a small time-window where we don't have the repo.
Yeah, that's correct! See #2603 which managed to trigger this with a very specific setup on CI. So far it's remained rare enough that this hasn't been a big priority just yet.
I am not sure if I am missing something but, if this seems possible and significant enough we can introduce something like a .forc_ready file. If a .forc_read file is not present, searching could wait until it is there (with a time limit). I believe i saw something similar in cargo somewhere but couldn't find it now 🤔
I think the long-term solution here might be something along the lines of #919. Edit: to clarify, we can leave that for a future PR!
forc-pkg/src/pkg.rs
Outdated
|
||
/// Search local checkouts directory and apply the given function. This is used for iterating over | ||
/// possible options of a given package. | ||
fn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, f: &mut F) -> Result<()> |
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.
fn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, f: &mut F) -> Result<()> | |
fn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, f: F) -> Result<()> |
We can take the function directly, no need to take by &mut
as &mut F
also implements FnMut
:)
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.
Hmm it seems like if I do this I am getting a compiler error at f(index, repo_dir_path)
line complaining about not being able to capture it mutably. Once I remove the unnecessary &mut
statements in front of the closures I pass to this function and change function signature to fn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, mut f: F) -> Result<()>
it works. I might be missing something but to get it compiling I had to go like the doc example
closes #1787.
unblocks #2365.