mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-12-10 22:45:27 +00:00
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:
parent
e5fdbcd480
commit
6c69c4e253
@ -29,20 +29,10 @@ import torch
|
|||||||
|
|
||||||
|
|
||||||
def get_git_sha1():
|
def get_git_sha1():
|
||||||
git_commit = (
|
try:
|
||||||
subprocess.run(
|
git_commit = (
|
||||||
["git", "rev-parse", "--short", "HEAD"],
|
|
||||||
check=True,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
)
|
|
||||||
.stdout.decode()
|
|
||||||
.rstrip("\n")
|
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
dirty_commit = (
|
|
||||||
len(
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["git", "diff", "--shortstat"],
|
["git", "rev-parse", "--short", "HEAD"],
|
||||||
check=True,
|
check=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
)
|
)
|
||||||
@ -50,39 +40,61 @@ def get_git_sha1():
|
|||||||
.rstrip("\n")
|
.rstrip("\n")
|
||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
> 0
|
dirty_commit = (
|
||||||
)
|
len(
|
||||||
git_commit = (
|
subprocess.run(
|
||||||
git_commit + "-dirty" if dirty_commit else git_commit + "-clean"
|
["git", "diff", "--shortstat"],
|
||||||
)
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.rstrip("\n")
|
||||||
|
.strip()
|
||||||
|
)
|
||||||
|
> 0
|
||||||
|
)
|
||||||
|
git_commit = (
|
||||||
|
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():
|
||||||
git_date = (
|
try:
|
||||||
subprocess.run(
|
git_date = (
|
||||||
["git", "log", "-1", "--format=%ad", "--date=local"],
|
subprocess.run(
|
||||||
check=True,
|
["git", "log", "-1", "--format=%ad", "--date=local"],
|
||||||
stdout=subprocess.PIPE,
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.rstrip("\n")
|
||||||
|
.strip()
|
||||||
)
|
)
|
||||||
.stdout.decode()
|
except: # noqa
|
||||||
.rstrip("\n")
|
return None
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
return git_date
|
return git_date
|
||||||
|
|
||||||
|
|
||||||
def get_git_branch_name():
|
def get_git_branch_name():
|
||||||
git_date = (
|
try:
|
||||||
subprocess.run(
|
git_date = (
|
||||||
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
subprocess.run(
|
||||||
check=True,
|
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
||||||
stdout=subprocess.PIPE,
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.rstrip("\n")
|
||||||
|
.strip()
|
||||||
)
|
)
|
||||||
.stdout.decode()
|
except: # noqa
|
||||||
.rstrip("\n")
|
return None
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
return git_date
|
return git_date
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user