Skip to content

Commit e5b405d

Browse files
committed
fix: classify decompression failures and merge current main
2 parents d899055 + 90c5773 commit e5b405d

18 files changed

Lines changed: 142 additions & 13 deletions

‎.all-contributorsrc‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,16 @@
990990
"test"
991991
]
992992
},
993+
{
994+
"login": "ewraj",
995+
"name": "Raj Royal",
996+
"avatar_url": "https://avatars.githubusercontent.com/u/212665522?v=4",
997+
"profile": "https://github.com/ewraj",
998+
"contributions": [
999+
"code",
1000+
"test"
1001+
]
1002+
},
9931003
{
9941004
"login": "snowyukitty",
9951005
"name": "snowyukitty",

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
460460
<td align="center"><a href="https://nandan.fyi"><img src="https://avatars.githubusercontent.com/u/74198723?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Nandan Varma</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Tests">⚠️</a></td>
461461
</tr>
462462
<tr>
463+
<td align="center"><a href="https://github.com/ewraj"><img src="https://avatars.githubusercontent.com/u/212665522?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Raj Royal</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Tests">⚠️</a></td>
463464
<td align="center"><a href="https://github.com/snowyukitty"><img src="https://avatars.githubusercontent.com/u/270071858?v=4?s=60" width="60px;" alt=""/><br /><sub><b>snowyukitty</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyukitty" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyukitty" title="Tests">⚠️</a></td>
464465
</tr>
465466
</table>

‎__tests__/test-GitConfig-in-submodule.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ describe('GitConfig', () => {
9090
const a = await config.get('remote.bar.url')
9191
expect(a).toEqual('https://bar.com/project.git')
9292
})
93+
94+
it('variable name with digits', async () => {
95+
const config = GitConfig.from(`[foo]
96+
key1 = val1
97+
key2aaa = val2`)
98+
const a = await config.get('foo.key1')
99+
expect(a).toEqual('val1')
100+
const b = await config.get('foo.key2aaa')
101+
expect(b).toEqual('val2')
102+
})
103+
104+
it('tabs around the equal sign', async () => {
105+
const config = GitConfig.from(`[foo]
106+
keyaaa = valaaa`)
107+
const a = await config.get('foo.keyaaa')
108+
expect(a).toEqual('valaaa')
109+
})
93110
})
94111

95112
describe('handle comments', () => {
@@ -269,6 +286,15 @@ describe('GitConfig', () => {
269286
keyaaa = valaaa`)
270287
})
271288

289+
it('variable name with digits', async () => {
290+
const config = GitConfig.from(`[foo]
291+
keyaaa = valaaa`)
292+
await config.set('foo.key2', 'val2')
293+
expect(config.toString()).toEqual(`[foo]
294+
key2 = val2
295+
keyaaa = valaaa`)
296+
})
297+
272298
it('existing section (case insensitive)', async () => {
273299
const config = GitConfig.from(`[foo]
274300
keyaaa = valaaa`)

‎__tests__/test-GitConfig.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ describe('GitConfig', () => {
9090
const a = await config.get('remote.bar.url')
9191
expect(a).toEqual('https://bar.com/project.git')
9292
})
93+
94+
it('variable name with digits', async () => {
95+
const config = GitConfig.from(`[foo]
96+
key1 = val1
97+
key2aaa = val2`)
98+
const a = await config.get('foo.key1')
99+
expect(a).toEqual('val1')
100+
const b = await config.get('foo.key2aaa')
101+
expect(b).toEqual('val2')
102+
})
103+
104+
it('tabs around the equal sign', async () => {
105+
const config = GitConfig.from(`[foo]
106+
keyaaa = valaaa`)
107+
const a = await config.get('foo.keyaaa')
108+
expect(a).toEqual('valaaa')
109+
})
93110
})
94111

95112
describe('handle comments', () => {
@@ -269,6 +286,15 @@ describe('GitConfig', () => {
269286
keyaaa = valaaa`)
270287
})
271288

289+
it('variable name with digits', async () => {
290+
const config = GitConfig.from(`[foo]
291+
keyaaa = valaaa`)
292+
await config.set('foo.key2', 'val2')
293+
expect(config.toString()).toEqual(`[foo]
294+
key2 = val2
295+
keyaaa = valaaa`)
296+
})
297+
272298
it('existing section (case insensitive)', async () => {
273299
const config = GitConfig.from(`[foo]
274300
keyaaa = valaaa`)

‎__tests__/test-GitError-in-submodule.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ describe('Errors', () => {
3333
}
3434
`)
3535
})
36+
it('serializes a DecompressionError without library-bug guidance', async () => {
37+
const error = new Errors.DecompressionError('buffer error')
38+
error.caller = 'git.readTree'
39+
expect(error instanceof Errors.DecompressionError).toBe(true)
40+
expect(error.isIsomorphicGitError).toBe(true)
41+
expect(error.code).toBe('DecompressionError')
42+
expect(error.message).toBe('Invalid compressed buffer: buffer error')
43+
expect(error.message).not.toMatch(/internal error|file an issue/)
44+
const json = JSON.parse(JSON.stringify(error))
45+
expect(json.data).toEqual({ message: 'buffer error' })
46+
const restored = error.fromJSON(json)
47+
expect(restored.toJSON().code).toBe(error.code)
48+
expect(restored.toJSON().data).toEqual(error.data)
49+
expect(restored.caller).toBe(error.caller)
50+
expect(restored.message).toBe(error.message)
51+
})
3652
it('create an InternalError with actionable reporting guidance', async () => {
3753
const e = new Errors.InternalError('Something unexpected happened.')
3854

‎__tests__/test-GitError.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ describe('Errors', () => {
3333
}
3434
`)
3535
})
36+
it('serializes a DecompressionError without library-bug guidance', async () => {
37+
const error = new Errors.DecompressionError('buffer error')
38+
error.caller = 'git.readTree'
39+
expect(error instanceof Errors.DecompressionError).toBe(true)
40+
expect(error.isIsomorphicGitError).toBe(true)
41+
expect(error.code).toBe('DecompressionError')
42+
expect(error.message).toBe('Invalid compressed buffer: buffer error')
43+
expect(error.message).not.toMatch(/internal error|file an issue/)
44+
const json = JSON.parse(JSON.stringify(error))
45+
expect(json.data).toEqual({ message: 'buffer error' })
46+
const restored = error.fromJSON(json)
47+
expect(restored.toJSON().code).toBe(error.code)
48+
expect(restored.toJSON().data).toEqual(error.data)
49+
expect(restored.caller).toBe(error.caller)
50+
expect(restored.message).toBe(error.message)
51+
})
3652
it('create an InternalError with actionable reporting guidance', async () => {
3753
const e = new Errors.InternalError('Something unexpected happened.')
3854

‎__tests__/test-browserInflate.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ describeNative('browserInflate', () => {
6161
if (original.message) {
6262
expect(error).toBe(original)
6363
} else {
64+
expect(error.code).toBe('DecompressionError')
65+
expect(error.isIsomorphicGitError).toBe(true)
6466
expect(error.message).toBe(
6567
'Invalid compressed buffer: decompression failed'
6668
)

‎__tests__/test-inflate.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ describe('inflate', () => {
4141
error = err
4242
}
4343
expect(error instanceof Error).toBe(true)
44-
expect(error.name).toBe('Error')
44+
expect(error.name).toBe('DecompressionError')
45+
expect(error.code).toBe('DecompressionError')
46+
expect(error.isIsomorphicGitError).toBe(true)
4547
expect(error.message).toMatch(/^Invalid compressed buffer: .+/)
4648
expect(error.message).not.toMatch(/internal error|file an issue/)
4749
})

‎__tests__/test-readObject-in-submodule.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,9 @@ describe('readObject', () => {
659659
error = err
660660
}
661661
expect(error instanceof Error).toBe(true)
662-
expect(error.name).toBe('Error')
662+
expect(error.name).toBe('DecompressionError')
663+
expect(error.code).toBe('DecompressionError')
664+
expect(error.isIsomorphicGitError).toBe(true)
663665
expect(error.caller).toBe('git.readObject')
664666
expect(error.message).toMatch(/^Invalid compressed buffer: .+/)
665667
}

‎__tests__/test-readObject.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,9 @@ describe('readObject', () => {
657657
error = err
658658
}
659659
expect(error instanceof Error).toBe(true)
660-
expect(error.name).toBe('Error')
660+
expect(error.name).toBe('DecompressionError')
661+
expect(error.code).toBe('DecompressionError')
662+
expect(error.isIsomorphicGitError).toBe(true)
661663
expect(error.caller).toBe('git.readObject')
662664
expect(error.message).toMatch(/^Invalid compressed buffer: .+/)
663665
}

0 commit comments

Comments
 (0)