diff --git a/test/helpers/shared-libs-eval-fixture.ts b/test/helpers/shared-libs-eval-fixture.ts index faefb039b..b533abdc8 100644 --- a/test/helpers/shared-libs-eval-fixture.ts +++ b/test/helpers/shared-libs-eval-fixture.ts @@ -326,7 +326,7 @@ function sharedCurlRequest(args: string[]) { else { try { const url = new URL(urls[0]); - const repoPath = /^\/repos\/fixture\/shared-libs(?:\/(?:contents\/.+|pulls(?:\/\d+(?:\/files)?)?|commits(?:\/(?:[a-f0-9]{40}|main))?|branches\/[^/]+))?$/; + const repoPath = /^\/repos\/fixture\/shared-libs(?:\/(?:contents\/.+|pulls(?:\/\d+(?:\/files)?)?|commits(?:\/(?:[a-f0-9]{40}|main))?|branches(?:\/[^/]+)?))?$/; if (url.protocol !== 'https:' || url.hostname !== 'api.github.com' || url.port || url.username || url.password || url.hash || (!repoPath.test(url.pathname) && url.pathname !== '/search/issues')) throw new Error('unsupported URL'); result.endpoint = url.pathname.slice(1) + url.search; @@ -685,6 +685,7 @@ else if(/\\/pulls\\/42(?:\\?|$)/.test(endpoint))out=pr(42,old); else if(/\\/pulls\\/\\d+(?:\\?|$)/.test(endpoint)){const row=prTable.find(row=>row.number===Number(endpoint.match(/\\/pulls\\/(\\d+)/)[1]));if(!row)apiError(404,'Not Found');out=toPr(row);} else if(endpoint.includes('/commits')){const isPrCommit=prHead!==${JSON.stringify(f.tip)}&&endpoint.includes(prHead);out=endpoint.includes('/commits/')?{sha:isPrCommit?prHead:${JSON.stringify(f.tip)},commit:{committer:{date:isPrCommit?old:now},message:'Fixture work'},files:Object.keys(isPrCommit?prFiles:files).map(filename=>({filename,status:'modified'}))}:[{sha:${JSON.stringify(f.tip)},commit:{committer:{date:now},message:'Fixture work'}}];} else if(endpoint.includes('/branches/'))out={name:'main',commit:{sha:${JSON.stringify(f.tip)}}}; +else if(/\\/branches(?:\\?|$)/.test(endpoint))out=[{name:'main',commit:{sha:${JSON.stringify(f.tip)}},protected:false}]; else if(/^\\/?repos\\/fixture\\/shared-libs\\/?(?:\\?|$)/.test(endpoint))out={default_branch:'main',full_name:'fixture/shared-libs',html_url:'https://github.com/fixture/shared-libs'}; else apiError(404,'Not Found'); if(curl)curlResponse(out); diff --git a/test/shared-libs-fixture.test.ts b/test/shared-libs-fixture.test.ts index f03a18ebc..24e281a34 100644 --- a/test/shared-libs-fixture.test.ts +++ b/test/shared-libs-fixture.test.ts @@ -1133,6 +1133,11 @@ describe('shared-code PR coverage world', () => { const missingPr = curl(f, ['-fsS', 'https://api.github.com/repos/fixture/shared-libs/pulls/999999']); expect(missingPr.status).toBe(22); expect(JSON.parse(gh(f, 'repos/fixture/shared-libs').stdout).default_branch).toBe('main'); + // Default-branch discovery may list branches; both transports serve the same one-branch world. + const branches = curl(f, ['-sS', 'https://api.github.com/repos/fixture/shared-libs/branches?per_page=100']); + expect(branches.status, branches.stderr).toBe(0); + expect(JSON.parse(branches.stdout)).toEqual(JSON.parse(gh(f, 'repos/fixture/shared-libs/branches?per_page=100').stdout)); + expect(JSON.parse(branches.stdout).map((b: { name: string }) => b.name)).toEqual(['main']); // The read-only detector still rejects a raw-host fallback. const raw = curl(f, ['-sS', `https://raw.githubusercontent.com/fixture/shared-libs/${f.tip}/src/retry-route.ts`]); expect(raw.status).toBe(2);