test(ext/sw): assert lastCommit URL structure + comment limit/per_page divergence
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,9 @@ describe('lastCommit (Gitea)', () => {
|
||||
const host = new GiteaHost('https://git.example.com', 'user/vault', 'tok');
|
||||
const result = await host.lastCommit('manifest.enc');
|
||||
expect(result).toEqual({ sha: 'abc1234', author: 'Alice', date: '2026-04-20T12:00:00Z' });
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('/repos/user/vault/commits');
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('path=manifest.enc');
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('limit=1');
|
||||
});
|
||||
|
||||
it('returns null on 404', async () => {
|
||||
@@ -45,6 +48,9 @@ describe('lastCommit (GitHub)', () => {
|
||||
const host = new GitHubHost('user/vault', 'tok');
|
||||
const result = await host.lastCommit('manifest.enc');
|
||||
expect(result).toEqual({ sha: 'def4567', author: 'Bob', date: '2026-04-22T15:00:00Z' });
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('/repos/user/vault/commits');
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('path=manifest.enc');
|
||||
expect(fetchSpy.mock.calls[0][0]).toContain('per_page=1');
|
||||
});
|
||||
|
||||
it('returns null when commits list is empty', async () => {
|
||||
|
||||
@@ -120,6 +120,7 @@ export class GiteaHost implements GitHost {
|
||||
|
||||
async lastCommit(path: string): Promise<{ sha: string; author: string; date: string } | null> {
|
||||
try {
|
||||
// Gitea uses 'limit'; GitHub's equivalent endpoint uses 'per_page'.
|
||||
const url = `${this.commitsUrl}?path=${encodeURIComponent(path)}&limit=1`;
|
||||
const resp = await fetch(url, { headers: this.headers });
|
||||
if (!resp.ok) return null;
|
||||
|
||||
Reference in New Issue
Block a user