Skip to content

Commit cf35d04

Browse files
changelog + fixed tests
1 parent 83b5c2d commit cf35d04

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Added ask sidebar to homepage. [#721](https://github.com/sourcebot-dev/sourcebot/pull/721)
1212
- Added endpoint for searching commit history for a git repository. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
1313
- Added `pushedAt` field to the Repo table to track when a repository last was committed to across all branches. [#790](https://github.com/sourcebot-dev/sourcebot/pull/790)
14+
- Added offset pagination to the `/api/repos` endpoint. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
15+
- Added offset pagination to the `/api/commits` endpoint. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
1416

1517
### Changed
1618
- Added commit graph generation to improve performance for commit traversal operations. [#791](https://github.com/sourcebot-dev/sourcebot/pull/791)
1719
- Made the code search `lang:` filter case insensitive. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
20+
- Changed the `/api/source` endpoint from a POST request to a GET request. Repo, path, and ref are specified as query params. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
21+
- Changed the `/api/commits` endpoint to be a POST request to a GET request. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
22+
- Renamed `webUrl` to `externalWebUrl` for various apis. Moving forward, `webUrl` will be used for URLs that point to Sourcebot, and `externalWebUrl` will be used for URLs that point to external code hosts. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
23+
- Renamed various fields on the `/api/source` endpoint response body. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
1824

1925
## [4.10.17] - 2026-01-23
2026

packages/mcp/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Added `search_commits` tool to search a repos commit history. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
1212
- Added `gitRevision` parameter to the `search_code` tool to allow for searching on different branches. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
13+
- Added server side pagination support for `list_commits` and `list_repos`. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
14+
- Added `filterByFilepaths` and `useRegex` params to the `search_code` tool. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
15+
16+
### Changed
17+
- Renamed `search_commits` tool to `list_commits`. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
18+
- Renamed `gitRevision` param to `ref` on `search_code` tool. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
19+
- Generally improved tool and tool param descriptions for all tools. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
1320

1421
## [1.0.12] - 2026-01-13
1522

packages/web/src/features/search/gitApi.test.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { existsSync } from 'fs';
6161

6262
describe('searchCommits', () => {
6363
const mockGitLog = vi.fn();
64+
const mockGitRaw = vi.fn();
6465
const mockCwd = vi.fn();
6566
const mockSimpleGit = simpleGit as unknown as vi.Mock;
6667
const mockExistsSync = existsSync as unknown as vi.Mock;
@@ -75,13 +76,16 @@ describe('searchCommits', () => {
7576
mockExistsSync.mockReturnValue(true);
7677
mockCwd.mockReturnValue({
7778
log: mockGitLog,
79+
raw: mockGitRaw,
7880
});
7981
mockSimpleGit.mockReturnValue({
8082
cwd: mockCwd,
8183
});
8284

8385
// Setup default repo mock
8486
mockFindFirst.mockResolvedValue({ id: 123, name: 'github.com/test/repo' });
87+
// Setup default raw mock for rev-list count
88+
mockGitRaw.mockResolvedValue('10');
8589
});
8690

8791
describe('repository validation', () => {
@@ -144,7 +148,7 @@ describe('searchCommits', () => {
144148
until: '2024-12-31',
145149
});
146150

147-
expect(Array.isArray(result)).toBe(true);
151+
expect(result).toMatchObject({ commits: [], totalCount: expect.any(Number) });
148152
});
149153
});
150154

@@ -199,6 +203,7 @@ describe('searchCommits', () => {
199203
expect(mockGitLog).toHaveBeenCalledWith(
200204
expect.objectContaining({
201205
maxCount: 50,
206+
HEAD: null,
202207
})
203208
);
204209
});
@@ -212,6 +217,7 @@ describe('searchCommits', () => {
212217
expect(mockGitLog).toHaveBeenCalledWith(
213218
expect.objectContaining({
214219
maxCount: 100,
220+
HEAD: null,
215221
})
216222
);
217223
});
@@ -225,6 +231,7 @@ describe('searchCommits', () => {
225231
expect(mockGitLog).toHaveBeenCalledWith(
226232
expect.objectContaining({
227233
'--since': '30 days ago',
234+
HEAD: null,
228235
})
229236
);
230237
});
@@ -238,6 +245,7 @@ describe('searchCommits', () => {
238245
expect(mockGitLog).toHaveBeenCalledWith(
239246
expect.objectContaining({
240247
'--until': 'yesterday',
248+
HEAD: null,
241249
})
242250
);
243251
});
@@ -251,6 +259,8 @@ describe('searchCommits', () => {
251259
expect(mockGitLog).toHaveBeenCalledWith(
252260
expect.objectContaining({
253261
'--author': 'john@example.com',
262+
'--regexp-ignore-case': null,
263+
HEAD: null,
254264
})
255265
);
256266
});
@@ -265,6 +275,7 @@ describe('searchCommits', () => {
265275
expect.objectContaining({
266276
'--grep': 'fix bug',
267277
'--regexp-ignore-case': null,
278+
HEAD: null,
268279
})
269280
);
270281
});
@@ -281,17 +292,18 @@ describe('searchCommits', () => {
281292

282293
expect(mockGitLog).toHaveBeenCalledWith({
283294
maxCount: 25,
295+
HEAD: null,
284296
'--since': '2024-01-01',
285297
'--until': '2024-12-31',
286298
'--author': 'jane@example.com',
287-
'--grep': 'feature',
288299
'--regexp-ignore-case': null,
300+
'--grep': 'feature',
289301
});
290302
});
291303
});
292304

293305
describe('successful responses', () => {
294-
it('should return commit array from git log', async () => {
306+
it('should return commits and totalCount from git log', async () => {
295307
const mockCommits = [
296308
{
297309
hash: 'abc123',
@@ -314,23 +326,25 @@ describe('searchCommits', () => {
314326
];
315327

316328
mockGitLog.mockResolvedValue({ all: mockCommits });
329+
mockGitRaw.mockResolvedValue('2');
317330

318331
const result = await listCommits({
319332
repo: 'github.com/test/repo',
320333
});
321334

322-
expect(result).toEqual(mockCommits);
335+
expect(result).toEqual({ commits: mockCommits, totalCount: 2 });
323336
});
324337

325-
it('should return empty array when no commits match', async () => {
338+
it('should return empty commits array when no commits match', async () => {
326339
mockGitLog.mockResolvedValue({ all: [] });
340+
mockGitRaw.mockResolvedValue('0');
327341

328342
const result = await listCommits({
329343
repo: 'github.com/test/repo',
330344
query: 'nonexistent',
331345
});
332346

333-
expect(result).toEqual([]);
347+
expect(result).toEqual({ commits: [], totalCount: 0 });
334348
});
335349
});
336350

@@ -442,6 +456,7 @@ describe('searchCommits', () => {
442456
vi.spyOn(dateUtils, 'validateDateRange').mockReturnValue(null);
443457
vi.spyOn(dateUtils, 'toGitDate').mockImplementation((date) => date);
444458
mockGitLog.mockResolvedValue({ all: mockCommits });
459+
mockGitRaw.mockResolvedValue('1');
445460

446461
const result = await listCommits({
447462
repo: 'github.com/test/repo',
@@ -452,14 +467,15 @@ describe('searchCommits', () => {
452467
maxCount: 20,
453468
});
454469

455-
expect(result).toEqual(mockCommits);
470+
expect(result).toEqual({ commits: mockCommits, totalCount: 1 });
456471
expect(mockGitLog).toHaveBeenCalledWith({
457472
maxCount: 20,
473+
HEAD: null,
458474
'--since': '30 days ago',
459475
'--until': 'yesterday',
460476
'--author': 'security',
461-
'--grep': 'authentication',
462477
'--regexp-ignore-case': null,
478+
'--grep': 'authentication',
463479
});
464480
});
465481

@@ -495,7 +511,7 @@ describe('searchCommits', () => {
495511
repo: 'github.com/owner/repo',
496512
});
497513

498-
expect(Array.isArray(result)).toBe(true);
514+
expect(result).toMatchObject({ commits: [], totalCount: expect.any(Number) });
499515
expect(mockFindFirst).toHaveBeenCalledWith({
500516
where: {
501517
name: 'github.com/owner/repo',
@@ -545,6 +561,7 @@ describe('searchCommits', () => {
545561
vi.spyOn(dateUtils, 'validateDateRange').mockReturnValue(null);
546562
vi.spyOn(dateUtils, 'toGitDate').mockImplementation((date) => date);
547563
mockGitLog.mockResolvedValue({ all: mockCommits });
564+
mockGitRaw.mockResolvedValue('1');
548565

549566
const result = await listCommits({
550567
repo: 'github.com/test/repository',
@@ -553,7 +570,7 @@ describe('searchCommits', () => {
553570
author: 'Developer',
554571
});
555572

556-
expect(result).toEqual(mockCommits);
573+
expect(result).toEqual({ commits: mockCommits, totalCount: 1 });
557574
expect(mockCwd).toHaveBeenCalledWith('/mock/cache/dir/555');
558575
});
559576
});

0 commit comments

Comments
 (0)