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

fix(resolver): Add general support for git-over-protocol URLs #4759

Merged
merged 3 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions __tests__/package-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function prepareRequest(pattern: string, version: string, resolved: string
return {request, reporter};
}

test('Produce valid remote type for a git private dep', async () => {
test('Produce valid remote type for a git-over-ssh dep', async () => {
const {request, reporter} = await prepareRequest(
'private-dep@github:yarnpkg/private-dep#1.0.0',
'1.0.0',
Expand All @@ -45,6 +45,32 @@ test('Produce valid remote type for a git private dep', async () => {
await reporter.close();
});

test('Produce valid remote type for a git-over-https dep', async () => {
const {request, reporter} = await prepareRequest(
'public-dep@yarnpkg/public-dep#1.0.0',
'1.0.0',
'git+https://github.com/yarnpkg/public-dep#1fde368',
);

expect(request.getLocked('git')._remote.type).toBe('git');
expect(request.getLocked('tarball')._remote.type).toBe('git');

await reporter.close();
});

test('Produce valid remote type for a git public dep', async () => {
const {request, reporter} = await prepareRequest(
'public-dep@yarnpkg/public-dep#1fde368',
'1.0.0',
'https://codeload.github.com/yarnpkg/public-dep/tar.gz/1fde368',
);

expect(request.getLocked('git')._remote.type).toBe('git');
expect(request.getLocked('tarball')._remote.type).toBe('tarball');

await reporter.close();
});

test('Check parentNames flowing in the request', async () => {
const {request: parentRequest, reporter: parentReporter} = await prepareRequest(
'parent@1.0.0',
Expand All @@ -63,16 +89,3 @@ test('Check parentNames flowing in the request', async () => {
await parentReporter.close();
await childReporter.close();
});

test('Produce valid remote type for a git public dep', async () => {
const {request, reporter} = await prepareRequest(
'public-dep@yarnpkg/public-dep#1fde368',
'1.0.0',
'https://codeload.github.com/yarnpkg/public-dep/tar.gz/1fde368',
);

expect(request.getLocked('git')._remote.type).toBe('git');
expect(request.getLocked('tarball')._remote.type).toBe('tarball');

await reporter.close();
});
5 changes: 3 additions & 2 deletions src/package-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export default class PackageRequest {

if (shrunk && shrunk.resolved) {
const resolvedParts = versionUtil.explodeHashedUrl(shrunk.resolved);
// If it's a private git url set remote to 'git'.
const preferredRemoteType = resolvedParts.url.startsWith('git+ssh://') ? 'git' : remoteType;

// Detect Git protocols (git://HOST/PATH or git+PROTOCOL://HOST/PATH)
const preferredRemoteType = /^git(\+[a-z0-9]+)?:\/\//.test(resolvedParts.url) ? 'git' : remoteType;

return {
name: shrunk.name,
Expand Down
52 changes: 7 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"

ansi-styles@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.0.0.tgz#5404e93a544c4fec7f048262977bebfe3155e0c1"
dependencies:
color-convert "^1.0.0"

ansi-styles@^3.1.0:
ansi-styles@^3.0.0, ansi-styles@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88"
dependencies:
Expand Down Expand Up @@ -788,21 +782,7 @@ babel-template@^6.16.0, babel-template@^6.24.1:
babylon "^6.11.0"
lodash "^4.2.0"

babel-traverse@^6.18.0, babel-traverse@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695"
dependencies:
babel-code-frame "^6.22.0"
babel-messages "^6.23.0"
babel-runtime "^6.22.0"
babel-types "^6.24.1"
babylon "^6.15.0"
debug "^2.2.0"
globals "^9.0.0"
invariant "^2.2.0"
lodash "^4.2.0"

babel-traverse@^6.23.1:
babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1"
dependencies:
Expand All @@ -816,16 +796,7 @@ babel-traverse@^6.23.1:
invariant "^2.2.0"
lodash "^4.2.0"

babel-types@^6.18.0, babel-types@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975"
dependencies:
babel-runtime "^6.22.0"
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babel-types@^6.23.0, babel-types@^6.25.0:
babel-types@^6.18.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.25.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e"
dependencies:
Expand All @@ -834,11 +805,11 @@ babel-types@^6.23.0, babel-types@^6.25.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0, babylon@^6.5.0:
babylon@^6.11.0, babylon@^6.17.0, babylon@^6.5.0:
version "6.17.1"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"

babylon@^6.17.0, babylon@^6.17.2, babylon@^6.17.4:
babylon@^6.13.0, babylon@^6.17.2, babylon@^6.17.4:
version "6.17.4"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a"

Expand Down Expand Up @@ -1159,7 +1130,7 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

color-convert@^1.0.0, color-convert@^1.9.0:
color-convert@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
dependencies:
Expand Down Expand Up @@ -1963,7 +1934,7 @@ find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"

findup-sync@0.4.2:
findup-sync@0.4.2, findup-sync@^0.4.2:
version "0.4.2"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.4.2.tgz#a8117d0f73124f5a4546839579fe52d7129fb5e5"
dependencies:
Expand All @@ -1972,15 +1943,6 @@ findup-sync@0.4.2:
micromatch "^2.3.7"
resolve-dir "^0.1.0"

findup-sync@^0.4.2:
version "0.4.3"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.4.3.tgz#40043929e7bc60adf0b7f4827c4c6e75a0deca12"
dependencies:
detect-file "^0.1.0"
is-glob "^2.0.1"
micromatch "^2.3.7"
resolve-dir "^0.1.0"

fined@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/fined/-/fined-1.0.2.tgz#5b28424b760d7598960b7ef8480dff8ad3660e97"
Expand Down