Skip to content

Commit

Permalink
fix(git-resolver): resolve commits via https
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 14, 2022
1 parent 4985aab commit 31a82ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-kids-clean.md
@@ -0,0 +1,5 @@
---
"@pnpm/git-resolver": patch
---

Resolve commits from GitHub via https.
6 changes: 2 additions & 4 deletions packages/git-resolver/src/parsePref.ts
Expand Up @@ -77,10 +77,7 @@ function urlToFetchSpec (urlparse: URL) {
async function fromHostedGit (hosted: any): Promise<HostedPackageSpec> { // eslint-disable-line
let fetchSpec: string | null = null
// try git/https url before fallback to ssh url

// Note only GitHub has gitTemplate (git://...) in hosted-git-info, has to use
// sshTemplate (git@...) for bitbucket and gitlab.
const gitUrl = hosted.git({ noCommittish: true }) ?? hosted.ssh({ noCommittish: true })
const gitUrl = hosted.https({ noCommittish: true }) ?? hosted.ssh({ noCommittish: true })
if (gitUrl && await accessRepository(gitUrl)) {
fetchSpec = gitUrl
}
Expand Down Expand Up @@ -137,6 +134,7 @@ async function fromHostedGit (hosted: any): Promise<HostedPackageSpec> { // esli

async function accessRepository (repository: string) {
try {
console.log(repository)
await git(['ls-remote', '--exit-code', repository, 'HEAD'], { retries: 0 })
return true
} catch (err: any) { // eslint-disable-line
Expand Down

0 comments on commit 31a82ed

Please sign in to comment.