From 545c8f128763cb2f76a831f69aee8745089c359b Mon Sep 17 00:00:00 2001 From: Ben Morrow Date: Mon, 15 Apr 2024 20:11:47 +0100 Subject: [PATCH] Handle empty repos which return capabilities (#1895) * docs: add @amrc-benmorrow as a contributor * Test empty response with capabilities --- .all-contributorsrc | 9 +++++++++ README.md | 1 + __tests__/test-wire.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3e45a142b..efa5c7108 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -678,6 +678,15 @@ "contributions": [ "code" ] + }, + { + "login": "amrc-benmorrow", + "name": "Ben Morrow", + "avatar_url": "https://avatars.githubusercontent.com/u/120477944?v=4", + "profile": "https://github.com/amrc-benmorrow", + "contributions": [ + "code" + ] } ], "commitConvention": "angular" diff --git a/README.md b/README.md index d625474fe..ecc499a64 100644 --- a/README.md +++ b/README.md @@ -369,6 +369,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
Sebastien

💻
Yaroslav Halchenko

📖
Alex Villarreal

💻 +
Ben Morrow

💻 diff --git a/__tests__/test-wire.js b/__tests__/test-wire.js index be3262f42..41b9115f0 100644 --- a/__tests__/test-wire.js +++ b/__tests__/test-wire.js @@ -171,6 +171,35 @@ describe('git wire protocol', () => { ['refs/heads/master5', 'e5c144897b64a44bd1164a0db60738452c9eaf87'], ]) }) + it('parseRefsAdResponse empty repo with capabilities', async () => { + const res = [ + Buffer.from(`001e# service=git-upload-pack +000000fa0000000000000000000000000000000000000000 capabilities^{}\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed no-done object-format=sha1 agent=git/2.43.0 +0000`), + ] + const result = await parseRefsAdResponse(res, { + service: 'git-upload-pack', + }) + expect([...result.capabilities]).toEqual([ + 'multi_ack', + 'thin-pack', + 'side-band', + 'side-band-64k', + 'ofs-delta', + 'shallow', + 'deepen-since', + 'deepen-not', + 'deepen-relative', + 'no-progress', + 'include-tag', + 'multi_ack_detailed', + 'no-done', + 'object-format=sha1', + 'agent=git/2.43.0', + ]) + expect([...result.symrefs]).toEqual([]) + expect([...result.refs]).toEqual([]) + }) it('parseRefsAdResponse bad service', async () => { const res = [ Buffer.from(`001e# noservice=git-upload-pack