global: dynamic version fix

* Fixes the cases where the call is made from outside a git repository.
  (Closes #2001)

Signed-off-by: Yoan Blanc <yoan.blanc@cern.ch>
Reported-by: Jan Åge Lavik <jan.age.lavik@cern.ch>