This change checks if the current source directory is a git repository. If this is not checked the git command picks the commit hash from parent directory. e.g. when tarball is extracted in a packaging repository.
In mingw build environment, this fixes the build error: 'py' is not recognized as an internal or external command The 'py' launcher is available for MSVC python only. More https://docs.python.org/3/using/windows.html#from-the-command-line