build: fix release name strings for gitian builds

When building from a distdir as gitian does, checking for the .git dir
is not reliable. Instead, ask git if we're in a repo.
Merge pull request #4946

c65cc8c build: fix release name strings for gitian builds (Cory Fields)