-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 support for private GitHub shortcuts deps #971
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,14 +35,25 @@ test('getGitHTTPUrl should return the correct git bitbucket url', () => { | |
expect(BitBucketResolver.getGitHTTPUrl(fragment)).toBe(expected); | ||
}); | ||
|
||
test('getGitHTTPUrl should return the correct git bitbucket SSH url', () => { | ||
test('getGitSSH should return the correct git bitbucket SSH url', () => { | ||
const fragment: ExplodedFragment = { | ||
user: 'foo', | ||
repo: 'bar', | ||
hash: '', | ||
}; | ||
|
||
const expected = '[email protected]:' + fragment.user + '/' + fragment.repo + '.git'; | ||
const expected = `[email protected]:${fragment.user}/${fragment.repo}.git`; | ||
expect(BitBucketResolver.getGitSSH(fragment)).toBe(expected); | ||
}); | ||
|
||
test('getGitSSHUrl should return the correct git bitbucket SSH url', () => { | ||
const fragment: ExplodedFragment = { | ||
user: 'foo', | ||
repo: 'bar', | ||
hash: '', | ||
}; | ||
|
||
const expected = `git+ssh://[email protected]/${fragment.user}/${fragment.repo}.git`; | ||
expect(BitBucketResolver.getGitSSHUrl(fragment)).toBe(expected); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,10 @@ export default class BitbucketResolver extends HostedGitResolver { | |
} | ||
|
||
static getGitSSHUrl(parts: ExplodedFragment): string { | ||
return `git+ssh://[email protected]/${ parts.user }/${ parts.repo }.git`; | ||
} | ||
|
||
static getGitSSH(parts: ExplodedFragment): string { | ||
return `[email protected]:${parts.user}/${parts.repo}.git`; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,11 @@ export default class GitHubResolver extends HostedGitResolver { | |
} | ||
|
||
static getGitSSHUrl(parts: ExplodedFragment): string { | ||
return `git+ssh://[email protected]/${ parts.user }/${ parts.repo }.git` + | ||
`${parts.hash ? '#' + decodeURIComponent(parts.hash) : ''}`; | ||
} | ||
|
||
static getGitSSH(parts: ExplodedFragment): string { | ||
return `git@${this.hostname}:${parts.user}/${parts.repo}.git` + | ||
`${parts.hash ? '#' + decodeURIComponent(parts.hash) : ''}`; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,10 @@ export default class GitLabResolver extends HostedGitResolver { | |
} | ||
|
||
static getGitSSHUrl(parts: ExplodedFragment): string { | ||
return `git+ssh://[email protected]/${ parts.user }/${ parts.repo }.git`; | ||
} | ||
|
||
static getGitSSH(parts: ExplodedFragment): string { | ||
return `[email protected]:${parts.user}/${parts.repo}.git`; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,11 @@ export default class HostedGitResolver extends ExoticResolver { | |
throw new Error('Not implemented'); | ||
} | ||
|
||
static getGitSSH(exploded: ExplodedFragment): string { | ||
exploded; | ||
throw new Error('Not implemented'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is actually the purpose of this? Why would you add call to this function and just throw an error in it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is what it does on all the methods of HostedGitResolver (src/resolvers/exotics/hosted-git-resolver.js) https://github.com/ramasilveyra/yarn/blob/efd9801987ef395a6a5ed30b3bc5e0cef94326b5/src/resolvers/exotics/hosted-git-resolver.js#L58-L84 |
||
} | ||
|
||
static getHTTPFileUrl(exploded: ExplodedFragment, filename: string, commit: string) { | ||
exploded; | ||
filename; | ||
|
@@ -170,14 +175,15 @@ export default class HostedGitResolver extends ExoticResolver { | |
} | ||
|
||
async resolve(): Promise<Manifest> { | ||
const httpUrl = this.constructor.getGitHTTPUrl(this.exploded); | ||
const sshUrl = this.constructor.getGitSSHUrl(this.exploded); | ||
const gitHTTPUrl = this.constructor.getGitHTTPUrl(this.exploded); | ||
const gitSSHUrl = this.constructor.getGitSSHUrl(this.exploded); | ||
const gitSSH = this.constructor.getGitSSH(this.exploded); | ||
|
||
// If we can access the files over HTTP then we should as it's MUCH faster than git | ||
// archive and tarball unarchiving. The HTTP API is only available for public repos | ||
// though. | ||
if (await this.hasHTTPCapability(httpUrl)) { | ||
return await this.resolveOverHTTP(httpUrl); | ||
if (await this.hasHTTPCapability(gitHTTPUrl)) { | ||
return await this.resolveOverHTTP(gitHTTPUrl); | ||
} | ||
|
||
// If the url is accessible over git archive then we should immediately delegate to | ||
|
@@ -186,13 +192,13 @@ export default class HostedGitResolver extends ExoticResolver { | |
// NOTE: Here we use a different url than when we delegate to the git resolver later on. | ||
// This is because `git archive` requires access over ssh and github only allows that | ||
// if you have write permissions | ||
if (await Git.hasArchiveCapability(sshUrl)) { | ||
const archiveClient = new Git(this.config, sshUrl, this.hash); | ||
if (await Git.hasArchiveCapability(gitSSH)) { | ||
const archiveClient = new Git(this.config, gitSSH, this.hash); | ||
const commit = await archiveClient.initRemote(); | ||
return await this.fork(GitResolver, true, `${sshUrl}#${commit}`); | ||
return await this.fork(GitResolver, true, `${gitSSH}#${commit}`); | ||
} | ||
|
||
// fallback to the plain git resolver | ||
return await this.fork(GitResolver, true, sshUrl); | ||
return await this.fork(GitResolver, true, gitSSHUrl); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice find!