Google Groups

Re: finding out Gerrit version


Shawn Pearce Jul 3, 2013 8:35 AM
Posted in group: Repo and Gerrit Discussion
On Wed, Jul 3, 2013 at 5:02 AM, Tomasz Zarna <tomasz...@tasktop.com> wrote:
> What's the most reliable way of finding out what's the version of a Gerrit
> server if the only thing I have is its URL?
>
> For example:
>
> checking https://gerrit.chromium.org should give me "2.7-rc2-637-g76c7890"
> https://gerrit.chromium.org -- "2.5.4"
> https://git.eclipse.org/r/#/ -- "2.6.1"
> and so on
>
> Ideally, I would like to be able to recognize ancient versions like 2.1.x as
> well.

There isn't a good way to do this. We didn't export the server version
of HTTP until master (aka 2.8), and even then its embedded into the
host page data object in the / HTML response. Which is never fun to
parse from a program.

But I did find a backdoor into the version for you. Its still not
pretty but may be workable.

Parse the HTML of https://gerrit-review.googlesource.com/tools/hooks/.
There is a "Powered by Gerrit Code Review" footer buried in an <p>
tag:

$ curl https://gerrit-review.googlesource.com/tools/hooks/
<html><head><META http-equiv="Content-Type" content="text/html;
charset=UTF-8"><title>Gerrit Code Review -
/tools/hooks</title></head><body><h1>Gerrit Code Review -
/tools/hooks</h1><ul><li><a
href="commit-msg">commit-msg</a></li></ul><hr><p style="text-align:
right; font-style: italic">Powered by Gerrit Code Review
2.7-rc2-647-gba149ce</p></body></html>

This feature first appeared in 2.1.2-rc0 and has been available
unmodified since.

A change to add /config/server/version as a REST API that can be more
reliably polled and parsed would be welcome.