aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/update.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/update.py')
-rw-r--r--yt_dlp/update.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/yt_dlp/update.py b/yt_dlp/update.py
index fc96f2985..e82cdf451 100644
--- a/yt_dlp/update.py
+++ b/yt_dlp/update.py
@@ -1,4 +1,5 @@
import atexit
+import contextlib
import hashlib
import json
import os
@@ -50,6 +51,19 @@ def detect_variant():
return VARIANT or _get_variant_and_executable_path()[0]
+@functools.cache
+def current_git_head():
+ if detect_variant() != 'source':
+ return
+ with contextlib.suppress(Exception):
+ stdout, _, _ = Popen.run(
+ ['git', 'rev-parse', '--short', 'HEAD'],
+ text=True, cwd=os.path.dirname(os.path.abspath(__file__)),
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if re.fullmatch('[0-9a-f]+', stdout.strip()):
+ return stdout.strip()
+
+
_FILE_SUFFIXES = {
'zip': '',
'py2exe': '_min.exe',