Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
ac15133
1
Parent(s):
5546927
feat: 当存在tag时,显示版本改用tag名称而非commit hash
Browse files- modules/utils.py +25 -4
modules/utils.py
CHANGED
@@ -538,24 +538,45 @@ def run(command, desc=None, errdesc=None, custom_env=None, live=False):
|
|
538 |
raise RuntimeError(message)
|
539 |
return result.stdout.decode(encoding="utf8", errors="ignore")
|
540 |
|
541 |
-
def
|
542 |
git = os.environ.get('GIT', "git")
|
543 |
-
python_version = ".".join([str(x) for x in sys.version_info[0:3]])
|
544 |
try:
|
545 |
commit_hash = run(f"{git} rev-parse HEAD").strip()
|
546 |
except Exception:
|
547 |
commit_hash = "<none>"
|
548 |
if commit_hash != "<none>":
|
549 |
short_commit = commit_hash[0:7]
|
550 |
-
commit_info = f
|
551 |
else:
|
552 |
commit_info = "unknown \U0001F615"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
return f"""
|
554 |
Python: <span title="{sys.version}">{python_version}</span>
|
555 |
•
|
556 |
Gradio: {gr.__version__}
|
557 |
•
|
558 |
-
<a style="text-decoration:none;color:inherit" href="https://github.com/GaiZhenbiao/ChuanhuChatGPT">ChuanhuChat</a>: {
|
559 |
"""
|
560 |
|
561 |
def get_html(filename):
|
|
|
538 |
raise RuntimeError(message)
|
539 |
return result.stdout.decode(encoding="utf8", errors="ignore")
|
540 |
|
541 |
+
def commit_html():
|
542 |
git = os.environ.get('GIT', "git")
|
|
|
543 |
try:
|
544 |
commit_hash = run(f"{git} rev-parse HEAD").strip()
|
545 |
except Exception:
|
546 |
commit_hash = "<none>"
|
547 |
if commit_hash != "<none>":
|
548 |
short_commit = commit_hash[0:7]
|
549 |
+
commit_info = f'<a style="text-decoration:none;color:inherit" href="https://github.com/GaiZhenbiao/ChuanhuChatGPT/commit/{short_commit}">{short_commit}</a>'
|
550 |
else:
|
551 |
commit_info = "unknown \U0001F615"
|
552 |
+
return commit_info
|
553 |
+
|
554 |
+
def tag_html():
|
555 |
+
git = os.environ.get('GIT', "git")
|
556 |
+
try:
|
557 |
+
tag = run(f"{git} describe --tags --exact-match").strip()
|
558 |
+
except Exception:
|
559 |
+
tag = "<none>"
|
560 |
+
if tag != "<none>":
|
561 |
+
tag_info = f'<a style="text-decoration:none;color:inherit" href="https://github.com/GaiZhenbiao/ChuanhuChatGPT/releases/tag/{tag}">{tag}</a>'
|
562 |
+
else:
|
563 |
+
tag_info = "unknown \U0001F615"
|
564 |
+
return tag_info
|
565 |
+
|
566 |
+
def repo_html():
|
567 |
+
commit_version = commit_html()
|
568 |
+
tag_version = tag_html()
|
569 |
+
return tag_version if tag_version != "unknown \U0001F615" else commit_version
|
570 |
+
|
571 |
+
def versions_html():
|
572 |
+
python_version = ".".join([str(x) for x in sys.version_info[0:3]])
|
573 |
+
repo_version = repo_html()
|
574 |
return f"""
|
575 |
Python: <span title="{sys.version}">{python_version}</span>
|
576 |
•
|
577 |
Gradio: {gr.__version__}
|
578 |
•
|
579 |
+
<a style="text-decoration:none;color:inherit" href="https://github.com/GaiZhenbiao/ChuanhuChatGPT">ChuanhuChat</a>: {repo_version}
|
580 |
"""
|
581 |
|
582 |
def get_html(filename):
|