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

Add `check_git_status(..., branch='master')` argument (#9199)

Add check_git_status(branch='master') argument Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 cf5d9cbc
...@@ -300,7 +300,7 @@ def git_describe(path=ROOT): # path must be a directory ...@@ -300,7 +300,7 @@ def git_describe(path=ROOT): # path must be a directory
@TryExcept() @TryExcept()
@WorkingDirectory(ROOT) @WorkingDirectory(ROOT)
def check_git_status(repo='ultralytics/yolov5'): def check_git_status(repo='ultralytics/yolov5', branch='master'):
# YOLOv5 status check, recommend 'git pull' if code is out of date # YOLOv5 status check, recommend 'git pull' if code is out of date
url = f'https://github.com/{repo}' url = f'https://github.com/{repo}'
msg = f', for updates see {url}' msg = f', for updates see {url}'
...@@ -316,10 +316,10 @@ def check_git_status(repo='ultralytics/yolov5'): ...@@ -316,10 +316,10 @@ def check_git_status(repo='ultralytics/yolov5'):
remote = 'ultralytics' remote = 'ultralytics'
check_output(f'git remote add {remote} {url}', shell=True) check_output(f'git remote add {remote} {url}', shell=True)
check_output(f'git fetch {remote}', shell=True, timeout=5) # git fetch check_output(f'git fetch {remote}', shell=True, timeout=5) # git fetch
branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).decode().strip() # checked out local_branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).decode().strip() # checked out
n = int(check_output(f'git rev-list {branch}..{remote}/master --count', shell=True)) # commits behind n = int(check_output(f'git rev-list {local_branch}..{remote}/{branch} --count', shell=True)) # commits behind
if n > 0: if n > 0:
pull = 'git pull' if remote == 'origin' else f'git pull {remote} master' pull = 'git pull' if remote == 'origin' else f'git pull {remote} {branch}'
s += f"⚠️ YOLOv5 is out of date by {n} commit{'s' * (n > 1)}. Use `{pull}` or `git clone {url}` to update." s += f"⚠️ YOLOv5 is out of date by {n} commit{'s' * (n > 1)}. Use `{pull}` or `git clone {url}` to update."
else: else:
s += f'up to date with {url} ✅' s += f'up to date with {url} ✅'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论