Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update check_git_status() to run under ROOT working directory #5441

Merged
merged 9 commits into from
Nov 2, 2021
5 changes: 4 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ def check_online():
def check_git_status():
# Recommend 'git pull' if code is out of date
msg = ', for updates see https://github.com/ultralytics/yolov5'
cwd = Path.cwd()
print(colorstr('github: '), end='')
assert Path('.git').exists(), 'skipping check (not a git repository)' + msg
assert Path(ROOT / '.git').exists(), 'skipping check (not a git repository)' + msg
assert not is_docker(), 'skipping check (Docker image)' + msg
assert check_online(), 'skipping check (offline)' + msg

os.chdir(ROOT) # Changing the current working directory to YOLOv5 repository root
cmd = 'git fetch && git config --get remote.origin.url'
url = check_output(cmd, shell=True, timeout=5).decode().strip().rstrip('.git') # git fetch
branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).decode().strip() # checked out
Expand All @@ -220,6 +222,7 @@ def check_git_status():
else:
s = f'up to date with {url} βœ…'
print(emojis(s)) # emoji-safe
os.chdir(cwd) # Reverting back to the original working directory


def check_python(minimum='3.6.2'):
Expand Down