Skip to content

Commit b4f5996

Browse files
Raymond Wangarcanis
Raymond Wang
authored andcommitted
Resolve Git dependencies offline if tarball is available. (#3000)
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.
1 parent f625912 commit b4f5996

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/resolvers/exotics/hosted-git-resolver.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type ExplodedFragment = {
1515
hash: string,
1616
};
1717

18-
export function explodeHostedGitFragment(fragment: string, reporter: Reporter): ExplodedFragment {
18+
export function explodeHostedGitFragment(fragment: string, reporter: Reporter): ExplodedFragment {
1919

2020
const preParts = fragment.split('@');
2121
if (preParts.length > 2) {
@@ -39,7 +39,7 @@ export function explodeHostedGitFragment(fragment: string, reporter: Reporter):
3939
throw new MessageError(reporter.lang('invalidHostedGitFragment', fragment));
4040
}
4141

42-
const userParts = fragment.split('/');
42+
const userParts = fragment.split('/');
4343

4444
if (userParts.length >= 2) {
4545

@@ -140,11 +140,6 @@ export default class HostedGitResolver extends ExoticResolver {
140140
}
141141

142142
async resolveOverHTTP(url: string): Promise<Manifest> {
143-
const shrunk = this.request.getLocked('tarball');
144-
if (shrunk) {
145-
return shrunk;
146-
}
147-
148143
const commit = await this.getRefOverHTTP(url);
149144
const {config} = this;
150145

@@ -201,6 +196,12 @@ export default class HostedGitResolver extends ExoticResolver {
201196
}
202197

203198
async resolve(): Promise<Manifest> {
199+
// If we already have the tarball, just return it without having to make any HTTP requests.
200+
const shrunk = this.request.getLocked('tarball');
201+
if (shrunk) {
202+
return shrunk;
203+
}
204+
204205
const httpUrl = this.constructor.getGitHTTPUrl(this.exploded);
205206
const httpBaseUrl = this.constructor.getGitHTTPBaseUrl(this.exploded);
206207
const sshUrl = this.constructor.getGitSSHUrl(this.exploded);

0 commit comments

Comments
 (0)