Skip to content

Commit 5a70fe0

Browse files
hemanthkiniisomorphic-git-bot
authored andcommitted
fix: do not incorrectly mark valid ref names as invalid (#2206)
* Add is-git-ref-name-valid import and use that when checking ref name * docs: add @hemanthkini as a contributor
1 parent 0d0c2f9 commit 5a70fe0

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

js/isomorphic-git/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
391391
<td align="center"><a href="https://github.com/ARBhosale"><img src="https://avatars.githubusercontent.com/u/26981417?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Aniket Bhosale</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Tests">⚠️</a></td>
392392
<td align="center"><a href="https://github.com/gnillev"><img src="https://avatars.githubusercontent.com/u/8965094?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mathias Nisted Velling</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Tests">⚠️</a></td>
393393
<td align="center"><a href="https://github.com/acandoo"><img src="https://avatars.githubusercontent.com/u/117209328?v=4?s=60" width="60px;" alt=""/><br /><sub><b>acandoo</b></sub></a><br /><a href="#platform-acandoo" title="Packaging/porting to new platform">📦</a> <a href="#userTesting-acandoo" title="User Testing">📓</a></td>
394+
<td align="center"><a href="https://github.com/hemanthkini"><img src="https://avatars.githubusercontent.com/u/3934055?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Hemanth Kini</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hemanthkini" title="Code">💻</a></td>
394395
</tr>
395396
</table>
396397

js/isomorphic-git/index.cjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var pako = _interopDefault(require('pako'));
1212
var pify = _interopDefault(require('pify'));
1313
var ignore = _interopDefault(require('ignore'));
1414
var cleanGitRef = _interopDefault(require('clean-git-ref'));
15+
var validRef = _interopDefault(require('is-git-ref-name-valid'));
1516
var diff3Merge = _interopDefault(require('diff3'));
1617

1718
/**
@@ -6143,7 +6144,7 @@ async function addNote({
61436144
*
61446145
*/
61456146
async function _addRemote({ fs, gitdir, remote, url, force }) {
6146-
if (remote !== cleanGitRef.clean(remote)) {
6147+
if (!validRef(remote, true)) {
61476148
throw new InvalidRefNameError(remote, cleanGitRef.clean(remote))
61486149
}
61496150
const config = await GitConfigManager.get({ fs, gitdir });
@@ -6415,7 +6416,7 @@ async function _branch({
64156416
checkout = false,
64166417
force = false,
64176418
}) {
6418-
if (ref !== cleanGitRef.clean(ref)) {
6419+
if (!validRef(ref, true)) {
64196420
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
64206421
}
64216422

@@ -14150,11 +14151,11 @@ async function _renameBranch({
1415014151
ref,
1415114152
checkout = false,
1415214153
}) {
14153-
if (ref !== cleanGitRef.clean(ref)) {
14154+
if (!validRef(ref, true)) {
1415414155
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
1415514156
}
1415614157

14157-
if (oldref !== cleanGitRef.clean(oldref)) {
14158+
if (!validRef(oldref, true)) {
1415814159
throw new InvalidRefNameError(oldref, cleanGitRef.clean(oldref))
1415914160
}
1416014161

@@ -16524,7 +16525,7 @@ async function writeRef({
1652416525

1652516526
const fs = new FileSystem(_fs);
1652616527

16527-
if (ref !== cleanGitRef.clean(ref)) {
16528+
if (!validRef(ref, true)) {
1652816529
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
1652916530
}
1653016531

js/isomorphic-git/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import pako from 'pako';
66
import pify from 'pify';
77
import ignore from 'ignore';
88
import cleanGitRef from 'clean-git-ref';
9+
import validRef from 'is-git-ref-name-valid';
910
import diff3Merge from 'diff3';
1011

1112
/**
@@ -6137,7 +6138,7 @@ async function addNote({
61376138
*
61386139
*/
61396140
async function _addRemote({ fs, gitdir, remote, url, force }) {
6140-
if (remote !== cleanGitRef.clean(remote)) {
6141+
if (!validRef(remote, true)) {
61416142
throw new InvalidRefNameError(remote, cleanGitRef.clean(remote))
61426143
}
61436144
const config = await GitConfigManager.get({ fs, gitdir });
@@ -6409,7 +6410,7 @@ async function _branch({
64096410
checkout = false,
64106411
force = false,
64116412
}) {
6412-
if (ref !== cleanGitRef.clean(ref)) {
6413+
if (!validRef(ref, true)) {
64136414
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
64146415
}
64156416

@@ -14144,11 +14145,11 @@ async function _renameBranch({
1414414145
ref,
1414514146
checkout = false,
1414614147
}) {
14147-
if (ref !== cleanGitRef.clean(ref)) {
14148+
if (!validRef(ref, true)) {
1414814149
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
1414914150
}
1415014151

14151-
if (oldref !== cleanGitRef.clean(oldref)) {
14152+
if (!validRef(oldref, true)) {
1415214153
throw new InvalidRefNameError(oldref, cleanGitRef.clean(oldref))
1415314154
}
1415414155

@@ -16518,7 +16519,7 @@ async function writeRef({
1651816519

1651916520
const fs = new FileSystem(_fs);
1652016521

16521-
if (ref !== cleanGitRef.clean(ref)) {
16522+
if (!validRef(ref, true)) {
1652216523
throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
1652316524
}
1652416525

js/isomorphic-git/index.umd.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/managers/index.umd.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/managers/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/models/index.umd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/models/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"crc-32": "^1.2.0",
106106
"diff3": "0.0.3",
107107
"ignore": "^5.1.4",
108+
"is-git-ref-name-valid": "^1.0.0",
108109
"minimisted": "^2.0.0",
109110
"pako": "^1.0.10",
110111
"path-browserify": "^1.0.1",

0 commit comments

Comments
 (0)