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

Resolve Git dependencies offline if tarball is available. #3000

Merged
merged 1 commit into from
May 1, 2017
Merged

Resolve Git dependencies offline if tarball is available. #3000

merged 1 commit into from
May 1, 2017

Conversation

raymondwang
Copy link
Contributor

Summary

When running yarn offline, Git dependencies get trapped in hasHTTPCapability even though resolveOverHTTP defaults to returning the tarball. This change allows us to bypass that step altogether if the tarball already exists.

Resolves #1925.

Test plan

Create a package.json with a Git dependency, like:

"nomnom": "douglasduteil/nomnom#next"

Then:

yarn
rm -r node_modules
yarn --offline

This should fail prior to this commit, but succeed after.

This change was first proposed in #2705, but @chrisgavin closed the PR and hasn't had a chance to revisit. I'm happy to add unit tests if/as needed, but may need some guidance on mocking offline functionality.

Copy link
Member

@arcanis arcanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @raymondwang! Thanks for this PR, it looks pretty good! Would you mind fixing my nit comment and rebasing your work on the master branch?

@@ -201,7 +201,7 @@ export default class HostedGitResolver extends ExoticResolver {
// If we can access the files over HTTP then we should as it's MUCH faster than git
// archive and tarball unarchiving. The HTTP API is only available for public repos
// though.
if (await this.hasHTTPCapability(httpUrl)) {
if (this.request.getLocked('tarball') || await this.hasHTTPCapability(httpUrl)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, but I think it would make more sense semantically speaking to just move those lines at the beginning of the resolve() function instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good to me!

When running yarn offline, Git dependencies get trapped in
hasHTTPCapabiity even though resolveOverHTTP defaults to returning
the tarball. This change allows us to bypass that step altogether
if the tarball already exists.
@raymondwang
Copy link
Contributor Author

@arcanis Done!

@arcanis arcanis merged commit b4f5996 into yarnpkg:master May 1, 2017
@arcanis
Copy link
Member

arcanis commented May 1, 2017

Thanks!

@DanBuild DanBuild mentioned this pull request May 2, 2017
@tp
Copy link

tp commented May 3, 2017

I am correct in assuming that this is not part of the just released yarn 0.23.4?

Because that one still fails for me with the "--offline" flag.

=> yarn --offline
yarn install v0.23.4
[1/4] 🔍  Resolving packages...
error Can't make a request in offline mode

If so, what release would this be included in then?

@arcanis
Copy link
Member

arcanis commented May 4, 2017

Yes. It will be released in the 0.24, which we want to publish later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot install packages from github when offline
3 participants