scripts: do more check before a git rev-parse
scripts: do more check before a git rev-parse

Handle the situation that the source tree does not contain .git .
Fix error: 'Fatal: Not a git repository'.

msbeta/apollo,msbeta/apollo,msbeta/apollo,msbeta/apollo,msbeta/apollo,msbeta/apollo