build: Keep Git revision in version for shallow clones

What does this MR do?

The version embedded in the Gitaly binary comes from git describe, which on a full clone yields the tag, commit count, and short revision. In a shallow clone there is no reachable tag, so git describe fails and we fall back to the VERSION file alone. The result is a bare version that no longer identifies the exact commit the binary was built from.

This falls back to the VERSION file and appends the short revision when git describe produces nothing, so gitaly --version still identifies the commit in a shallow clone.

Resulting version:

Build source Before After
Full clone 19.2.0-rc1-322-gcd716d3f0 19.2.0-rc1-322-gcd716d3f0 (unchanged)
Shallow clone (--depth=1) 19.2.0-rc1 19.2.0-rc1-gcd716d3
Tarball / no .git 19.2.0-rc1 19.2.0-rc1 (unchanged)

This mirrors the same fix made for Workhorse in gitlab!249163 (merged).

References

Edited by Stan Hu

Merge request reports

Loading
Loading