forked from yarnpkg/yarn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resolution): Allow "git+file:" dependency url protocol.
Allow "git_file:" dependency protocol to use a local un-pushed git repo as a dependency. Fix bug where local directories named "*.git" were treated as git dependencies fixes yarnpkg#3670 yarnpkg#5017
- Loading branch information
Showing
7 changed files
with
109 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
__tests__/fixtures/install/local-named-git/deps/a.git/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "a", | ||
"version": "1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"a": "file:./deps/a.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* @flow */ | ||
|
||
import GitResolver from '../../../src/resolvers/exotics/git-resolver.js'; | ||
|
||
test('isVersion true for ssh: protocol', () => { | ||
expect(GitResolver.isVersion('ssh://[email protected]/sindresorhus/beeper.git')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for git: protocol', () => { | ||
expect(GitResolver.isVersion('git://[email protected]/sindresorhus/beeper.git')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for git+ssh: protocol', () => { | ||
expect(GitResolver.isVersion('git+ssh://[email protected]/sindresorhus/beeper.git')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for http: protocol when ends with .git', () => { | ||
expect(GitResolver.isVersion('http://example.com/sindresorhus/beeper.git')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for http: protocol when ends with .git and hash', () => { | ||
expect(GitResolver.isVersion('http://example.com/sindresorhus/beeper.git#branch')).toBe(true); | ||
}); | ||
|
||
test('isVersion false for http: protocol when does not end with .git', () => { | ||
expect(GitResolver.isVersion('http://example.com/sindresorhus/beeper')).toBe(false); | ||
}); | ||
|
||
test('isVersion false for http: protocol when does not end with .git with hash', () => { | ||
expect(GitResolver.isVersion('http://example.com/sindresorhus/beeper#branch')).toBe(false); | ||
}); | ||
|
||
test('isVersion true for https: protocol when ends with .git', () => { | ||
expect(GitResolver.isVersion('https://example.com/sindresorhus/beeper.git')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for https: protocol when ends with .git and hash', () => { | ||
expect(GitResolver.isVersion('https://example.com/sindresorhus/beeper.git#branch')).toBe(true); | ||
}); | ||
|
||
test('isVersion false for https: protocol when does not end with .git', () => { | ||
expect(GitResolver.isVersion('https://example.com/sindresorhus/beeper')).toBe(false); | ||
}); | ||
|
||
test('isVersion false for https: protocol when does not end with .git with hash', () => { | ||
expect(GitResolver.isVersion('https://example.com/sindresorhus/beeper#branch')).toBe(false); | ||
}); | ||
|
||
test('isVersion false for file: protocol when ends with .git', () => { | ||
expect(GitResolver.isVersion('file:../project.git')).toBe(false); | ||
}); | ||
|
||
test('isVersion true for any github.com repo url', () => { | ||
expect(GitResolver.isVersion('foo://github.com/sindresorhus/beeper')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for any gitlab.com repo url', () => { | ||
expect(GitResolver.isVersion('foo://gitlab.com/sindresorhus/beeper')).toBe(true); | ||
}); | ||
|
||
test('isVersion true for any bitbucket.com repo url', () => { | ||
expect(GitResolver.isVersion('foo://bitbucket.com/sindresorhus/beeper')).toBe(true); | ||
}); | ||
|
||
test('isVersion false for any github url to archive file', () => { | ||
expect(GitResolver.isVersion('http://github.com/sindresorhus/beeper/archive/v1.0.0.tar.gz')).toBe(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,12 @@ test('npmUrlToGitUrl', () => { | |
hostname: 'github.com', | ||
repository: 'ssh://[email protected]/npm-opam/ocamlfind', | ||
}); | ||
expect(Git.npmUrlToGitUrl('file:../ocalmfind.git')).toEqual({ | ||
expect(Git.npmUrlToGitUrl('git+file:../ocalmfind.git')).toEqual({ | ||
protocol: 'file:', | ||
hostname: null, | ||
repository: '../ocalmfind.git', | ||
}); | ||
expect(Git.npmUrlToGitUrl('git+file:../ocalmfind')).toEqual({ | ||
protocol: 'file:', | ||
hostname: null, | ||
repository: '../ocalmfind', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters