From 36725697daa4d9f26d57cb584f077bc7a6916d6d Mon Sep 17 00:00:00 2001 From: Raymond Wang Date: Mon, 27 Mar 2017 12:47:44 -0400 Subject: [PATCH] Resolve Git dependencies offline if tarball is available. 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. --- src/resolvers/exotics/hosted-git-resolver.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/resolvers/exotics/hosted-git-resolver.js b/src/resolvers/exotics/hosted-git-resolver.js index 19d71239cd..7f2f902518 100644 --- a/src/resolvers/exotics/hosted-git-resolver.js +++ b/src/resolvers/exotics/hosted-git-resolver.js @@ -15,7 +15,7 @@ export type ExplodedFragment = { hash: string, }; -export function explodeHostedGitFragment(fragment: string, reporter: Reporter): ExplodedFragment { +export function explodeHostedGitFragment(fragment: string, reporter: Reporter): ExplodedFragment { const preParts = fragment.split('@'); if (preParts.length > 2) { @@ -39,7 +39,7 @@ export function explodeHostedGitFragment(fragment: string, reporter: Reporter): throw new MessageError(reporter.lang('invalidHostedGitFragment', fragment)); } - const userParts = fragment.split('/'); + const userParts = fragment.split('/'); if (userParts.length >= 2) { @@ -140,11 +140,6 @@ export default class HostedGitResolver extends ExoticResolver { } async resolveOverHTTP(url: string): Promise { - const shrunk = this.request.getLocked('tarball'); - if (shrunk) { - return shrunk; - } - const commit = await this.getRefOverHTTP(url); const {config} = this; @@ -201,6 +196,12 @@ export default class HostedGitResolver extends ExoticResolver { } async resolve(): Promise { + // If we already have the tarball, just return it without having to make any HTTP requests. + const shrunk = this.request.getLocked('tarball'); + if (shrunk) { + return shrunk; + } + const httpUrl = this.constructor.getGitHTTPUrl(this.exploded); const httpBaseUrl = this.constructor.getGitHTTPBaseUrl(this.exploded); const sshUrl = this.constructor.getGitSSHUrl(this.exploded);