Support running icefall outside of a git tracked directory. (#470)

* Support running icefall outside of a git tracked directory.

* Minor fixes.
This commit is contained in:
Fangjun Kuang 2022-07-08 15:03:07 +08:00 committed by GitHub
parent e5fdbcd480
commit 6c69c4e253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@ import torch
def get_git_sha1(): def get_git_sha1():
try:
git_commit = ( git_commit = (
subprocess.run( subprocess.run(
["git", "rev-parse", "--short", "HEAD"], ["git", "rev-parse", "--short", "HEAD"],
@ -55,10 +56,14 @@ def get_git_sha1():
git_commit = ( git_commit = (
git_commit + "-dirty" if dirty_commit else git_commit + "-clean" git_commit + "-dirty" if dirty_commit else git_commit + "-clean"
) )
except: # noqa
return None
return git_commit return git_commit
def get_git_date(): def get_git_date():
try:
git_date = ( git_date = (
subprocess.run( subprocess.run(
["git", "log", "-1", "--format=%ad", "--date=local"], ["git", "log", "-1", "--format=%ad", "--date=local"],
@ -69,10 +74,14 @@ def get_git_date():
.rstrip("\n") .rstrip("\n")
.strip() .strip()
) )
except: # noqa
return None
return git_date return git_date
def get_git_branch_name(): def get_git_branch_name():
try:
git_date = ( git_date = (
subprocess.run( subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], ["git", "rev-parse", "--abbrev-ref", "HEAD"],
@ -83,6 +92,9 @@ def get_git_branch_name():
.rstrip("\n") .rstrip("\n")
.strip() .strip()
) )
except: # noqa
return None
return git_date return git_date