Unverified 提交 b1cf25dd authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

check_git_status() asserts (#1977)

上级 e9941d50
...@@ -7,8 +7,8 @@ RUN apt update && apt install -y screen libgl1-mesa-glx ...@@ -7,8 +7,8 @@ RUN apt update && apt install -y screen libgl1-mesa-glx
# Install python dependencies # Install python dependencies
RUN pip install --upgrade pip RUN pip install --upgrade pip
COPY requirements.txt . COPY requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt gsutil wandb
RUN pip install gsutil RUN wandb disabled
# Create working directory # Create working directory
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
......
...@@ -60,16 +60,19 @@ def check_git_status(): ...@@ -60,16 +60,19 @@ def check_git_status():
# Recommend 'git pull' if code is out of date # Recommend 'git pull' if code is out of date
print(colorstr('github: '), end='') print(colorstr('github: '), end='')
try: try:
if Path('.git').exists() and not Path('/workspace').exists() and check_online(): # not exist '/.dockerenv' assert Path('.git').exists(), 'skipping check (not a git repository)'
url = subprocess.check_output( assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists()
'git fetch && git config --get remote.origin.url', shell=True).decode('utf-8')[:-1] assert check_online(), 'skipping check (offline)'
n = int(subprocess.check_output(
'git rev-list $(git rev-parse --abbrev-ref HEAD)..origin/master --count', shell=True)) # commits behind cmd = 'git fetch && git config --get remote.origin.url' # github repo url
if n > 0: url = subprocess.check_output(cmd, shell=True).decode()[:-1]
print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. " cmd = 'git rev-list $(git rev-parse --abbrev-ref HEAD)..origin/master --count' # commits behind
f"Use 'git pull' to update or 'git clone {url}' to download latest.") n = int(subprocess.check_output(cmd, shell=True))
else: if n > 0:
print(f'up to date with {url} ✅') print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. "
f"Use 'git pull' to update or 'git clone {url}' to download latest.")
else:
print(f'up to date with {url} ✅')
except Exception as e: except Exception as e:
print(e) print(e)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论