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

Allow git+***:// dependencies #3735

Merged
merged 3 commits into from
Jun 28, 2017
Merged

Allow git+***:// dependencies #3735

merged 3 commits into from
Jun 28, 2017

Conversation

Volune
Copy link
Contributor

@Volune Volune commented Jun 27, 2017

Summary

Fixing #3677

yarn add git+file:///path/to/git/repo#branch is not supported, it'll try to find the package in npm registry.
It does work in NPM (5.0.3).

Expected behavior: file:///path/to/git/repo#branch should be treated as a git remote repository, the same way as if it was accessed by SSH or HTTPS.

Test plan

Adding some tests on getExoticResolver to ensure the Git resolver is used for git+file:/// dependencies.

Implementation notes

I moved getExoticResolver to src/resolvers/index.js, I think it's more suitable than src/package-request.js, and more convenient to write the tests. I also refactored at little to make the returned type more specific.

I made the Git resolver handle any protocol prefixed with git+, not only git+file. That way, yarn will handle as many protocols as git itself does.

@bestander
Copy link
Member

nice work, @Volune!

@bestander bestander merged commit 8918da1 into yarnpkg:master Jun 28, 2017
Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Great work!

@@ -12,8 +12,10 @@ import Git from '../../util/git.js';

const urlParse = require('url').parse;

const GIT_PROTOCOL_PATTERN = /git\+.+:/;
Copy link
Member

Choose a reason for hiding this comment

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

Since we're using patterns now, do you think we can remove GIT_PROTOCOLS and special casing for https:// + ends with .git custom rules and bake them into the pattern in the future?

@mbahiense
Copy link

Great!! o/

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.

4 participants