warner/python-versioneer — Issue #1: skip 'git describe' call unless .git exists
Author: warner
Created: 2012-01-14 01:17:39+00:00
State: open

https://bugzilla.mozilla.org/show_bug.cgi?id=718115 (which is about a copy of Versioneer that I put into Jetpack) is about a leaked error message that occurs when the version-determining code tries to run `git describe` in a tree that has no .git directory. (In jetpack's case, this is because we have a git-to-mercurial bridge to support some legacy test automation, so they're running code that comes from an hg checkout, which of course has no .git directory).

The version-checking code correctly resolves version="unknown", but emits a scary "fatal: Not a git repository" message to stderr in the process.

The fix is to do an extra `os.path.isdir(".git")` check before calling `git describe`, and return None if `.git` is not present.