The new wiki link for the one @hnyman gave is now https://openwrt.org/docs/guide-developer/source-code/source-revision-calculation
Not completely clear from reading the script that it can take its own obscure output (the git hash seems to be something to do with a merge base, not the current commit), and return the git commit. (wiki now updated)
lede_source$ git describe
v17.01.4-215-g05f0fac
lede_source$ ./scripts/getver.sh
r2993+783-b9a408c
lede_source$ ./scripts/getver.sh r2993+783-b9a408c
05f0fac189984981e3f28288e44d9afdd088dd77
I'm still at a loss as to why the git hash isn't at least part of the version string.