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.