再妥协一下

This commit is contained in:
shenjack 2024-04-20 22:51:06 +08:00
parent df15584b62
commit a661d55d1f
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -8,14 +8,21 @@ ON_CF = os.getenv("CF_PAGES") == "1"
if ON_CF:
print("Running on Cloudflare Pages, trying to git fetch --all")
# add remote
run(
["git", "remote", "add", "origin", "https://github.com/shenjackyuanjie/fast-namerena.git"],
)
result = run(["git", "fetch", "--all"], check=False)
print(f"git fetch --all: {result.stdout}")
print(f"git fetch --all: {result}")
def get_env_info() -> dict[str, str]:
# 读取环境变量
env_info = {}
# git branch
if ON_CF:
branch = os.getenv("CF_PAGES_BRANCH") or "unknown"
else:
branch = run(
["git", "branch", "--show-current"],
capture_output=True,
@ -24,6 +31,9 @@ def get_env_info() -> dict[str, str]:
).stdout
env_info["branch"] = branch.strip()
# git commit hash
if ON_CF:
commit = os.getenv("CF_PAGES_COMMIT_SHA") or "unknown"
else:
commit = run(
["git", "rev-parse", "HEAD"],
capture_output=True,
@ -40,6 +50,9 @@ def get_env_info() -> dict[str, str]:
)
env_info["message"] = message.stdout.strip()
# git tag
if ON_CF:
tag = "cf_pages"
else:
tag = run(
["git", "describe", "--tags"], capture_output=True, text=True, encoding="utf-8"
).stdout