This commit is contained in:
shenjack 2024-04-20 22:15:39 +08:00
parent 77f3e2b460
commit 7394146e6a
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -7,19 +7,19 @@ def get_env_info() -> dict[str, str]:
env_info = {} env_info = {}
# git branch # git branch
branch = run( branch = run(
"git branch --show-current", capture_output=True, text=True, encoding="utf-8" ["git", "branch", "--show-current"], capture_output=True, text=True, encoding="utf-8"
) )
env_info["branch"] = branch.stdout.strip() env_info["branch"] = branch.stdout.strip()
# git commit hash # git commit hash
commit = run("git rev-parse HEAD", capture_output=True, text=True, encoding="utf-8") commit = run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, encoding="utf-8")
env_info["commit"] = commit.stdout.strip() env_info["commit"] = commit.stdout.strip()
# git commit message # git commit message
message = run( message = run(
"git log -1 --pretty=%B", capture_output=True, text=True, encoding="utf-8" ["git", "log", "-1", "--pretty=%B"], capture_output=True, text=True, encoding="utf-8"
) )
env_info["message"] = message.stdout.strip() env_info["message"] = message.stdout.strip()
# git tag # git tag
tag = run("git describe --tags", capture_output=True, text=True, encoding="utf-8") tag = run(["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8")
env_info["tag"] = tag.stdout.strip() env_info["tag"] = tag.stdout.strip()
return env_info return env_info