Fix Workhorse version for branch and shallow clone builds

What does this MR do?

Plain git describe walks history back to the nearest annotated tag, which in the GitLab monorepo is an ancient/unrelated tag. On regular branches this produced nonsensical Workhorse versions such as 11-10-0cfa69752d8-74ffd66ae-ee-415057-gecfde96bb7cc, and in a shallow clone (no reachable tags) git describe failed outright with fatal: No names found.

This changes the version logic in workhorse/Makefile to only trust git describe when HEAD is exactly at a release tag; otherwise it falls back to the VERSION file and appends the short commit SHA when a git repository is present.

Resulting main.Version:

Build source Before After
Release tag (exact match) v19.2.1-ee v19.2.1-ee (unchanged)
Branch (full clone) v12.3.0.pre-448932-g<sha> v19.3.0-pre-g<sha>
Shallow clone (--depth=1) fatal: No names found then v19.3.0-pre v19.3.0-pre-g<sha>
Tarball / no .git v19.3.0-pre v19.3.0-pre

This unblocks building Workhorse from a shallow clone.

References

Edited by Stan Hu

Merge request reports

Loading
Loading