diqiu50 commented on code in PR #4700:
URL: https://github.com/apache/gravitino/pull/4700#discussion_r1732312066
##########
clients/client-python/scripts/generate_version.py:
##########
@@ -17,17 +17,36 @@
under the License.
"""
+# coding=utf-8
+
import re
import configparser
-import subprocess
from datetime import datetime
+from gravitino.constants.root import PROJECT_ROOT
from gravitino.constants.version import Version, VERSION_INI, SETUP_FILE
from gravitino.exceptions.base import GravitinoRuntimeException
VERSION_PATTERN = r"version\s*=\s*['\"]([^'\"]+)['\"]"
+def get_git_commit_id():
+ try:
+ commit_id = ""
+ git_path = f"{PROJECT_ROOT}/.git/"
+ with open(git_path + "HEAD", "r", encoding="utf-8") as file:
+ ref = file.readline().strip()
+
+ if ref.startswith("ref:"):
+ ref_path = ref.split(" ")[1]
+ with open(git_path + ref_path, "r", encoding="utf-8") as file:
+ commit_id = file.readline().strip()
+ return commit_id
+ except (FileNotFoundError, IOError) as e:
+ print(f"Warn: Failed to get git commit Id. {e}")
Review Comment:
I remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]