[infra][tact-sig] Extracting commits data for the first and the last code review revisions

Jeremy Stanley fungi at yuggoth.org
Mon Mar 22 15:41:34 UTC 2021


[I'm keeping you in Cc since you don't appear to be subscribed to
this mailing list.]

On 2021-03-22 15:00:03 +0000 (+0000), Chouchen, Moataz wrote:
[...]
> I extracted the revision IDs for the first and the last revisions
> (supposed to be first and last commit hashes) for each code review
> in puppet projects. However, when we have more than one revision,
> we were unable to find the commits for the first revision in the
> git for all the projects and we only have commits data for the
> last revision. I would like to know if the commit of the first
> revision does exist in the CVS, and it's possible to extract?
[...]

Conveniently, Gerrit stores all of this in the repository and we
replicate it to our Git server farm. The complication is that,
because of the amend/rebase-oriented nature of Gerrit's code review
workflow, those earlier revisions don't appear in the branch
history. Instead, they are tracked with named references which look
like changes/XX/YYYY/Z where YYYY is the numeric index identifier
for the change, XX is the last two digits of YYYY (for sharding
purposes), and Z is the revision number starting from 1. Let's take
this puppet-nova change as an example:

    https://opendev.org/openstack/puppet-nova/commit/d385ca8

There you can see Gitea is displaying an indicator that there is a
named ref of changes/63/764763/5 associated with the commit. That
means it was revision 5 of change 764763 in Gerrit. You can fetch
that ref like so:

    git fetch origin changes/63/764763/5

That will fill FETCH_HEAD which you can then use with checkout,
show, or any other relevant subcommands. Conveniently, if you
instead want the first revision of 764763, all you have to do
differently is adjust the revision number:

    git fetch origin changes/63/764763/1

Hopefully that's what you're looking for?
-- 
Jeremy Stanley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-discuss/attachments/20210322/fc3b430a/attachment.sig>


More information about the openstack-discuss mailing list