fix: use git rev-parse HEAD for update checks when .git exists
This commit is contained in:
1 parent
1c9cc471e2
commit
fb672a16bd
1 file changed
+11
-1
+11
-1
@@ -69,7 +69,17 @@ class UpdateService:
|
|||||||
data = json.loads(resp.read().decode())
|
data = json.loads(resp.read().decode())
|
||||||
remote_sha = data['sha'][:7]
|
remote_sha = data['sha'][:7]
|
||||||
|
|
||||||
# Get current version from local VERSION file
|
# Get current version from git if available, otherwise VERSION file
|
||||||
|
git_dir = os.path.join(self.project_root, '.git')
|
||||||
|
if os.path.isdir(git_dir):
|
||||||
|
try:
|
||||||
|
local_sha = subprocess.check_output(
|
||||||
|
['git', 'rev-parse', 'HEAD'],
|
||||||
|
cwd=self.project_root, stderr=subprocess.DEVNULL
|
||||||
|
).decode().strip()[:7]
|
||||||
|
except Exception:
|
||||||
|
local_sha = "unknown"
|
||||||
|
else:
|
||||||
version_file = os.path.join(self.project_root, 'VERSION')
|
version_file = os.path.join(self.project_root, 'VERSION')
|
||||||
if os.path.exists(version_file):
|
if os.path.exists(version_file):
|
||||||
with open(version_file) as f:
|
with open(version_file) as f:
|
||||||
|
|||||||
Reference in new issue
Block a user