build/tools/get_migen/litex_git_revision: avoid git fatal error message is not installed as a git repository

This commit is contained in:
Florent Kermarrec 2019-11-19 09:11:11 +01:00
parent 02bfda5e38
commit d905521185
1 changed files with 4 additions and 2 deletions

View File

@ -109,7 +109,8 @@ def get_migen_git_revision():
d = os.getcwd()
os.chdir(os.path.dirname(migen.__file__))
try:
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])[:-1].decode("utf-8")
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"],
stderr=subprocess.DEVNULL)[:-1].decode("utf-8")
except:
r = "--------"
os.chdir(d)
@ -120,7 +121,8 @@ def get_litex_git_revision():
d = os.getcwd()
os.chdir(os.path.dirname(litex.__file__))
try:
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])[:-1].decode("utf-8")
r = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"],
stderr=subprocess.DEVNULL)[:-1].decode("utf-8")
except:
r = "--------"
os.chdir(d)