Skip to content

Commit

Permalink
Add check_git_status(..., branch='master') argument (#9199)
Browse files Browse the repository at this point in the history
Add check_git_status(branch='master') argument

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
glenn-jocher authored Aug 29, 2022
1 parent cf5d9cb commit f65081c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def git_describe(path=ROOT): # path must be a directory

@TryExcept()
@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
url = f'https://github.com/{repo}'
msg = f', for updates see {url}'
Expand All @@ -316,10 +316,10 @@ def check_git_status(repo='ultralytics/yolov5'):
remote = 'ultralytics'
check_output(f'git remote add {remote} {url}', shell=True)
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
n = int(check_output(f'git rev-list {branch}..{remote}/master --count', shell=True)) # commits behind
local_branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).decode().strip() # checked out
n = int(check_output(f'git rev-list {local_branch}..{remote}/{branch} --count', shell=True)) # commits behind
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."
else:
s += f'up to date with {url} ✅'
Expand Down

0 comments on commit f65081c

Please sign in to comment.