Skip to content

Some commits not syncing with Gerrit-hosted git repository

Created by: marekweb

While syncing git revisions from Gerrit, I'm trying to identify why some revisions are syncing and other revisions don't seem to be syncing.

Gerrit hosts git repositories and can be synced on Sourcegraph by adding it as a "Generic git host".

Instead of using branches, Gerrit puts commits that contain changes to be reviewed under the namespace refs/changes followed by a change identifier.

For example on the test repok8s-gerrit, only one branch exists, but multiple commits exist under refs/changes revisions because multiple changes have been created for code review in Gerrit.

git ls-remote
From https://gerrit.sgdev.org/k8s-gerrit
24d53f6b6c4f484c41697c35d5a790d045faf6a6        HEAD
976be7314788979fb5a9dcb23d06b0151e4626f4        refs/changes/01/1/1
fea70804f1ae21cb462bbcb5eef32ebefec622b3        refs/changes/01/1/meta
584a10336bbd70dc107582afd96352dbf4a625e8        refs/changes/02/2/1
5e1262686bc61f7b0f8f3682f8a7da34eb07e2d6        refs/changes/02/2/2
9ebdb4a4cdbe89752121aa66187c1bdcb4c1054a        refs/changes/02/2/meta
24d53f6b6c4f484c41697c35d5a790d045faf6a6        refs/heads/master

Steps to reproduce

Have the Gerrit repo added as a generic git host with configuration:

{
  "url": "https://gerrit.sgdev.org",
  "repos": ["k8s-gerrit", "src-cli"]
}

Open revision refs/changes/01/1/1 on Sourcegraph Open revision refs/changes/02/2/1 on Sourcegraph

Expected behavior

Both revision links open the repo at the given revision on Sourcegraph

Actual behavior

The first link opens, and the second link shows a 404.

The second link to revision refs/changes/02/2/1 should be equivalent to commit 584a103 but that also shows a 404.