Add support for cursor based pagination in the FindCommits RPC

While working on [Spike] Investigate potential architecture for ... (#535989 - closed) I noticed that we currently paginate the commit list using an offset.

This has the potential to cause the page to render a commit multiple times if we paginate after a new commit has been added to the current branch/tag:

  1. Navigate to the commit page
  2. From another tab or a terminal, add a new commit to the default branch
  3. Back on the commit page, scroll to the bottom of the page and load the next page of commits

The page will show the last commit twice. This is because we don't know what was already loaded and we used offset to figure out where the next page should start. Imagine a single page only showed 2 commits. We already have 4 commits in the repo, i.e. [4, 3, 2, 1]. The first time we load the page we see 4 and 3, then 5 is pushed to the branch but we've already loaded the page. Now we scroll down which triggers us to attempt to load 2 commits and offset by 2, normally this would load 2 and 1, however the commits now looks like [5, 4, 3, 2, 1] so we actually return 3, 2.

To fix this we need to switch to cursor based pagination. We already support this for other RPCs

To enable this we also need to update the response to include a next_cursor which will be passed in the next request's pagination params as page_token

Edited by 🤖 GitLab Bot 🤖