Public: anyone can read this; the crew can change it.

GET a repository's commits answers `{ items, next_cursor }`, and every test that reads it is updated #16929

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

GET /api/v1/repos/:owner/:name/commits now answers { items, nextcursor } instead of a bare array. It pages with ?cursor=. I ran only a handful of test files, not the full suite.

Notes

opened this

GET /api/v1/repos/:owner/:name/commits now answers { items, next_cursor } instead of a bare array. It pages with ?cursor=.

I ran only a handful of test files, not the full suite. bun x tsc --noEmit and the gate's --explain run were clean. scripts/fast.ts named 3,767 files, too many to run here. The 8 test files I touched, plus api-list-shape (see below), came out green after one fix. I ran the whole bun scripts/gate.ts --fix before committing; it printed nothing. The forge's check runs everything on the push.

  • Cursor: next_cursor is the last oid on the page, or null at the end of the log. Passing it as ?cursor= continues the log after that commit. A malformed cursor, or an oid that is no longer in the repository, is a 422 invalid_cursor.
  • ETag: the tag now includes the cursor, so two pages never share one.
  • Docs and contract: the OpenAPI route text, its cursor query and docs/features/list-limit.md say the same.
  • Tests:
    • I removed the route from the BARE allowlist in test/api-list-shape.test.ts, so a bare array there now fails.
    • Seven tests that read the old array now read .items: commits-etag, api-commits-timing, api-commit-timing, origin-pull-state, read-api, parity and origin-read-only-profile. The origin-read-only-profile one already read .items, so I left it unchanged.
    • A new test in commits-etag.test.ts walks two pages and checks the 422s.
  • Terminal and MCP: the commits MCP tool still answers { commits: [...] }, and the terminal and page views read commits through core code, not this route. I didn't change them, and the commit line says No door: with that reason.
  • Left out: a filter for which commits a cursor may name. A cursor can be any commit in the repository, not only one on ref's history.

Try it: curl "$FORGE_URL/api/v1/repos/<owner>/<name>/commits?limit=1", then pass the returned next_cursor as ?cursor=.

🤖 Generated with Claude Code

Closes #5083

2 earlier comments
commented

GET /api/v1/repos/:owner/:name/commits now answers { items, next_cursor } instead of a bare array. It pages with ?cursor=.

I ran only a handful of test files, not the full suite. bun x tsc --noEmit and the gate's --explain run were clean. scripts/fast.ts named 3,767 files, too many to run here. The 8 test files I touched, plus api-list-shape (see below), came out green after one fix. I ran the whole bun scripts/gate.ts --fix before committing; it printed nothing. The forge's check runs everything on the push.

  • Cursor: next_cursor is the last oid on the page, or null at the end of the log. Passing it as ?cursor= continues the log after that commit. A malformed cursor, or an oid that is no longer in the repository, is a 422 invalid_cursor.
  • ETag: the tag now includes the cursor, so two pages never share one.
  • Docs and contract: the OpenAPI route text, its cursor query and docs/features/list-limit.md say the same.
  • Tests:
    • I removed the route from the BARE allowlist in test/api-list-shape.test.ts, so a bare array there now fails.
    • Seven tests that read the old array now read .items: commits-etag, api-commits-timing, api-commit-timing, origin-pull-state, read-api, parity and origin-read-only-profile. The origin-read-only-profile one already read .items, so I left it unchanged.
    • A new test in commits-etag.test.ts walks two pages and checks the 422s.
  • Terminal and MCP: the commits MCP tool still answers { commits: [...] }, and the terminal and page views read commits through core code, not this route. I didn't change them, and the commit line says No door: with that reason.
  • Left out: a filter for which commits a cursor may name. A cursor can be any commit in the repository, not only one on ref's history.

Try it: curl "$FORGE_URL/api/v1/repos/<owner>/<name>/commits?limit=1", then pass the returned next_cursor as ?cursor=.

🤖 Generated with Claude Code

commented

GET /api/v1/repos/<owner>/<name>/commits now answers { items, next_cursor } and takes ?cursor= to continue; the earlier bare array is gone.

This push: the check's red tests, test/view-source.test.ts and test/web-browse.test.ts, still read the commits response as an array. Both now read .items. These two files pass, and tsc is clean. I didn't run the full suite here; the forge runs it on this push.

Not caused by this pull: test/talk-infra-says.test.ts is also red on main, and the check doesn't count it against this pull.

What I chose not to do: the terminal still reads the log through core and shows it unchanged, so there is no src/tui/ change.

To try it: curl $FORGE_URL/api/v1/repos/<owner>/<name>/commits?limit=1, then follow next_cursor as ?cursor=.

commented

GET /api/v1/repos/:owner/:name/commits now answers { items, next_cursor }, and scripts/home-eval.ts reads .items[0] instead of log[0]. Before this fix, every repo was silently treated as not quiet. I ran test/commits-etag.test.ts (7 pass) and tsc --noEmit. The gate reported only a long comment on line 1 of that test file, which was already there. I did not run the other tests that read the route.

  • Other readers: I searched outside test/ for readers of /api/v1/repos/*/commits and found none besides home-eval.ts. The crew brief only prints a curl line, so it is unchanged.
  • ref with cursor: I chose to document it rather than refuse. The route's OpenAPI detail now says that once a cursor is given, ref is ignored and the cursor's own history is paged. A malformed cursor, or one naming no commit, is a 422 invalid_cursor. A cursor that is not on ref's history is still accepted.
  • New test: ?ref=side&cursor=<oid> returns exactly what ?cursor=<oid> returns alone, so the behaviour is pinned.

The etag still includes ref, so ?ref=x&cursor=… and ?ref=y&cursor=… get different etags for the same body. That costs a cache miss but cannot serve a wrong page. I left it rather than special-case the key.

To try it: curl $FORGE_URL/api/v1/repos/<owner>/<name>/commits?limit=1, then follow next_cursor as ?cursor=.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs