From 23c6ed4a5581c6b167de05203596c5502682323e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 11:25:07 -0800 Subject: [PATCH 1/7] check_git_status() Windows fix --- utils/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index 37534799c157..19eca4a88cf1 100755 --- a/utils/general.py +++ b/utils/general.py @@ -66,7 +66,7 @@ def check_git_status(): cmd = 'git fetch && git config --get remote.origin.url' # github repo url url = subprocess.check_output(cmd, shell=True).decode()[:-1] - cmd = 'git rev-list $(git rev-parse --abbrev-ref HEAD)..origin/master --count' # commits behind + cmd = 'git rev-list $(git branch --show-current)..origin/master --count' # commits behind n = int(subprocess.check_output(cmd, shell=True)) if n > 0: print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. " From 23dcdfe5427744f7cd2325c9d90f410aca77e8b5 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 11:30:20 -0800 Subject: [PATCH 2/7] Update general.py --- utils/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index 19eca4a88cf1..d33f98ec3634 100755 --- a/utils/general.py +++ b/utils/general.py @@ -66,7 +66,7 @@ def check_git_status(): cmd = 'git fetch && git config --get remote.origin.url' # github repo url url = subprocess.check_output(cmd, shell=True).decode()[:-1] - cmd = 'git rev-list $(git branch --show-current)..origin/master --count' # commits behind + cmd = 'git rev-list ${git branch --show-current}..origin/master --count' # commits behind n = int(subprocess.check_output(cmd, shell=True)) if n > 0: print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. " From fcb0c7e19af37951f00fd2271073da0ef5cc2c92 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 11:42:18 -0800 Subject: [PATCH 3/7] Update general.py --- utils/general.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/general.py b/utils/general.py index d33f98ec3634..71fb4bcd9b08 100755 --- a/utils/general.py +++ b/utils/general.py @@ -64,10 +64,10 @@ def check_git_status(): assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists() assert check_online(), 'skipping check (offline)' - cmd = 'git fetch && git config --get remote.origin.url' # github repo url - url = subprocess.check_output(cmd, shell=True).decode()[:-1] - cmd = 'git rev-list ${git branch --show-current}..origin/master --count' # commits behind - n = int(subprocess.check_output(cmd, shell=True)) + cmd = 'git fetch && git config --get remote.origin.url' + url = subprocess.check_output(cmd, shell=True).decode().rstrip() # github repo url + branch = subprocess.check_output('git branch --show-current', shell=True).decode().rstrip() # current branch + n = int(subprocess.check_output(f'git rev-list {branch}..origin/master --count', shell=True)) # commits behind if n > 0: 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.") From e4b24de67853aba36b3ad57bada3df6284c9b749 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 11:51:36 -0800 Subject: [PATCH 4/7] Update general.py --- utils/general.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/general.py b/utils/general.py index 71fb4bcd9b08..391a51e9e68e 100755 --- a/utils/general.py +++ b/utils/general.py @@ -64,9 +64,9 @@ def check_git_status(): assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists() assert check_online(), 'skipping check (offline)' - cmd = 'git fetch && git config --get remote.origin.url' - url = subprocess.check_output(cmd, shell=True).decode().rstrip() # github repo url - branch = subprocess.check_output('git branch --show-current', shell=True).decode().rstrip() # current branch + cmd = 'git fetch && git config --get remote.origin.url' # github repo url + url = subprocess.check_output(cmd, shell=True).decode('utf-8').rstrip() + branch = subprocess.check_output('git branch --show-current', shell=True).decode('utf-8').rstrip() # current n = int(subprocess.check_output(f'git rev-list {branch}..origin/master --count', shell=True)) # commits behind if n > 0: print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. " From 6b12e6a30a9595981d29f6fffa4198501bbf6f0a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 12:02:07 -0800 Subject: [PATCH 5/7] Update general.py --- utils/general.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/general.py b/utils/general.py index 391a51e9e68e..5a5f954b8e8e 100755 --- a/utils/general.py +++ b/utils/general.py @@ -59,6 +59,8 @@ def check_online(): def check_git_status(): # Recommend 'git pull' if code is out of date print(colorstr('github: '), end='') + print('test 2 ✅', end='') + print('test 1 ⚠', end='') try: assert Path('.git').exists(), 'skipping check (not a git repository)' assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists() From 31fb3327689702eefc02c68cb2d4759ada3fd1a9 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 12:18:04 -0800 Subject: [PATCH 6/7] Update general.py --- utils/general.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/utils/general.py b/utils/general.py index 5a5f954b8e8e..ce20a4996d23 100755 --- a/utils/general.py +++ b/utils/general.py @@ -59,22 +59,21 @@ def check_online(): def check_git_status(): # Recommend 'git pull' if code is out of date print(colorstr('github: '), end='') - print('test 2 ✅', end='') - print('test 1 ⚠', end='') try: assert Path('.git').exists(), 'skipping check (not a git repository)' assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists() assert check_online(), 'skipping check (offline)' cmd = 'git fetch && git config --get remote.origin.url' # github repo url - url = subprocess.check_output(cmd, shell=True).decode('utf-8').rstrip() - branch = subprocess.check_output('git branch --show-current', shell=True).decode('utf-8').rstrip() # current + url = subprocess.check_output(cmd, shell=True).decode().rstrip() + branch = subprocess.check_output('git branch --show-current', shell=True).decode().rstrip() # current n = int(subprocess.check_output(f'git rev-list {branch}..origin/master --count', shell=True)) # commits behind if n > 0: - 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.") + s = 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} ✅') + s = f'up to date with {url} ✅' + print(s.encode().decode('ascii', 'ignore') if platform.system() == 'Windows' else s) except Exception as e: print(e) From b789fccd6be819170f9dda39cba54f5c7eb0b80d Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 22 Jan 2021 12:22:55 -0800 Subject: [PATCH 7/7] Update general.py --- utils/general.py | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/general.py b/utils/general.py index ce20a4996d23..aa137ebde5ff 100755 --- a/utils/general.py +++ b/utils/general.py @@ -4,6 +4,7 @@ import logging import math import os +import platform import random import re import subprocess