Skip to content

Commit 3234743

Browse files
authored
Autocorrects git:// into https:// for GitHub (#5440)
* Autocorrects git:// into https:// * Updates the url
1 parent a4da4e8 commit 3234743

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

.yarn/versions/8ca5de64.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/plugin-git": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-github"
11+
- "@yarnpkg/plugin-init"
12+
- "@yarnpkg/plugin-interactive-tools"
13+
- "@yarnpkg/plugin-nm"
14+
- "@yarnpkg/plugin-npm-cli"
15+
- "@yarnpkg/plugin-pack"
16+
- "@yarnpkg/plugin-patch"
17+
- "@yarnpkg/plugin-pnp"
18+
- "@yarnpkg/plugin-pnpm"
19+
- "@yarnpkg/plugin-stage"
20+
- "@yarnpkg/plugin-typescript"
21+
- "@yarnpkg/plugin-version"
22+
- "@yarnpkg/plugin-workspace-tools"
23+
- "@yarnpkg/builder"
24+
- "@yarnpkg/core"
25+
- "@yarnpkg/doctor"

packages/plugin-git/sources/gitUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function normalizeRepoUrl(url: string, {git = false}: {git?: boolean} = {
121121
url = url.replace(/^git\+https:/, `https:`);
122122

123123
// We support this as an alias to GitHub repositories
124-
url = url.replace(/^(?:github:|https:\/\/github\.com\/)?(?!\.{1,2}\/)([a-zA-Z0-9._-]+)\/(?!\.{1,2}(?:#|$))([a-zA-Z0-9._-]+?)(?:\.git)?(#.*)?$/, `https://github.com/$1/$2.git$3`);
124+
url = url.replace(/^(?:github:|https:\/\/github\.com\/|git:\/\/github\.com\/)?(?!\.{1,2}\/)([a-zA-Z0-9._-]+)\/(?!\.{1,2}(?:#|$))([a-zA-Z0-9._-]+?)(?:\.git)?(#.*)?$/, `https://github.com/$1/$2.git$3`);
125125

126126
// We support GitHub `/tarball/` URLs
127127
url = url.replace(/^https:\/\/github\.com\/(?!\.{1,2}\/)([a-zA-Z0-9._-]+)\/(?!\.{1,2}(?:#|$))([a-zA-Z0-9._-]+?)\/tarball\/(.+)?$/, `https://github.com/$1/$2.git#$3`);

packages/plugin-git/tests/__snapshots__/gitUtils.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ exports[`gitUtils should properly normalize git+ssh://[email protected]:yarnpkg/ber
4848

4949
exports[`gitUtils should properly normalize git+ssh://[email protected]:yarnpkg/berry.git#v2.1.1 ({ git: true }) 1`] = `"ssh://[email protected]/yarnpkg/berry.git#v2.1.1"`;
5050

51-
exports[`gitUtils should properly normalize git://github.com/yarnpkg/util-deprecate.git#v1.0.1 ({ git: false }) 1`] = `"git://github.com/yarnpkg/util-deprecate.git#v1.0.1"`;
51+
exports[`gitUtils should properly normalize git://github.com/yarnpkg/util-deprecate.git#v1.0.1 ({ git: false }) 1`] = `"https://github.com/yarnpkg/util-deprecate.git#v1.0.1"`;
5252

53-
exports[`gitUtils should properly normalize git://github.com/yarnpkg/util-deprecate.git#v1.0.1 ({ git: true }) 1`] = `"git://github.com/yarnpkg/util-deprecate.git#v1.0.1"`;
53+
exports[`gitUtils should properly normalize git://github.com/yarnpkg/util-deprecate.git#v1.0.1 ({ git: true }) 1`] = `"https://github.com/yarnpkg/util-deprecate.git#v1.0.1"`;
5454

5555
exports[`gitUtils should properly normalize github:GitHubOrg/foo-bar.js ({ git: false }) 1`] = `"https://github.com/GitHubOrg/foo-bar.js.git"`;
5656

@@ -227,7 +227,7 @@ exports[`gitUtils should properly split git+ssh://[email protected]:yarnpkg/berry.g
227227
exports[`gitUtils should properly split git://github.com/yarnpkg/util-deprecate.git#v1.0.1 1`] = `
228228
{
229229
"extra": {},
230-
"repo": "git://github.com/yarnpkg/util-deprecate.git",
230+
"repo": "https://github.com/yarnpkg/util-deprecate.git",
231231
"treeish": {
232232
"protocol": null,
233233
"request": "v1.0.1",

0 commit comments

Comments
 (0)