mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
feat: add "refs/" as a git resolution prefix (#4953)
Previously, if you wanted to check out a git PR branch, you needed to specify the url as: `github:pnpm/pnpm#refs/pull/123/merge`. Now this will resolve without the leading "refs": `github:pnpm/pnpm#pull/123/merge` close #2045
This commit is contained in:
5
.changeset/hip-sheep-smoke.md
Normal file
5
.changeset/hip-sheep-smoke.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/git-resolver": minor
|
||||
---
|
||||
|
||||
Add `refs/` to git resolution prefixes
|
||||
@@ -87,6 +87,7 @@ function resolveRefFromRefs (refs: {[ref: string]: string}, repo: string, ref: s
|
||||
if (!range) {
|
||||
const commitId =
|
||||
refs[ref] ||
|
||||
refs[`refs/${ref}`] ||
|
||||
refs[`refs/tags/${ref}^{}`] || // prefer annotated tags
|
||||
refs[`refs/tags/${ref}`] ||
|
||||
refs[`refs/heads/${ref}`]
|
||||
|
||||
@@ -72,6 +72,18 @@ test('resolveFromGit() with branch', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('resolveFromGit() with branch relative to refs', async () => {
|
||||
const resolveResult = await resolveFromGit({ pref: 'zkochan/is-negative#heads/canary' })
|
||||
expect(resolveResult).toStrictEqual({
|
||||
id: 'github.com/zkochan/is-negative/4c39fbc124cd4944ee51cb082ad49320fab58121',
|
||||
normalizedPref: 'github:zkochan/is-negative#heads/canary',
|
||||
resolution: {
|
||||
tarball: 'https://codeload.github.com/zkochan/is-negative/tar.gz/4c39fbc124cd4944ee51cb082ad49320fab58121',
|
||||
},
|
||||
resolvedVia: 'git-repository',
|
||||
})
|
||||
})
|
||||
|
||||
test('resolveFromGit() with tag', async () => {
|
||||
const resolveResult = await resolveFromGit({ pref: 'zkochan/is-negative#2.0.1' })
|
||||
expect(resolveResult).toStrictEqual({
|
||||
|
||||
Reference in New Issue
Block a user