更新: 1 个文件 - 2026-03-18 07:33:19

这个提交包含在:
hao
2026-03-18 07:33:19 -07:00
父节点 509281cfe9
当前提交 63d89f2b0c

查看文件

@@ -63,6 +63,14 @@ run_with_retries() {
done done
} }
git_remote_cmd() {
if git "$@"; then
return 0
fi
log_warning "Git 远端操作失败,切换到 HTTP/1.1 + relaxed SSL 兼容模式重试"
git -c http.sslVerify=false -c http.version=HTTP/1.1 "$@"
}
repo_api_url() { repo_api_url() {
echo "${GITEA_API}/repos/${GIT_USER}/${REPO_NAME}" echo "${GITEA_API}/repos/${GIT_USER}/${REPO_NAME}"
} }
@@ -72,7 +80,7 @@ repo_git_url() {
} }
remote_repo_reachable() { remote_repo_reachable() {
run_with_retries git ls-remote --exit-code origin HEAD >/dev/null 2>&1 run_with_retries git_remote_cmd ls-remote --exit-code origin HEAD >/dev/null 2>&1
} }
current_branch_name() { current_branch_name() {
@@ -238,9 +246,9 @@ push_changes() {
# 推送 # 推送
if [ -n "$GITEA_TOKEN" ]; then if [ -n "$GITEA_TOKEN" ]; then
run_with_retries git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push -u origin "$branch" run_with_retries git_remote_cmd -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push -u origin "$branch"
else else
run_with_retries git push -u origin "$branch" run_with_retries git_remote_cmd push -u origin "$branch"
fi fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
log_success "推送完成: $branch" log_success "推送完成: $branch"
@@ -250,13 +258,13 @@ push_changes() {
fi fi
if [ "$AUTO_PUSH_MAIN" = "1" ]; then if [ "$AUTO_PUSH_MAIN" = "1" ]; then
if run_with_retries git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then if run_with_retries git_remote_cmd ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
if run_with_retries git fetch origin main:refs/remotes/origin/main >/dev/null 2>&1; then if run_with_retries git_remote_cmd fetch origin main:refs/remotes/origin/main >/dev/null 2>&1; then
if git merge-base --is-ancestor refs/remotes/origin/main HEAD; then if git merge-base --is-ancestor refs/remotes/origin/main HEAD; then
if [ -n "$GITEA_TOKEN" ]; then if [ -n "$GITEA_TOKEN" ]; then
run_with_retries git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main run_with_retries git_remote_cmd -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main
else else
run_with_retries git push origin HEAD:main run_with_retries git_remote_cmd push origin HEAD:main
fi fi
git branch -f main HEAD >/dev/null 2>&1 || true git branch -f main HEAD >/dev/null 2>&1 || true
log_success "main 已快进到当前提交" log_success "main 已快进到当前提交"
@@ -268,9 +276,9 @@ push_changes() {
fi fi
else else
if [ -n "$GITEA_TOKEN" ]; then if [ -n "$GITEA_TOKEN" ]; then
run_with_retries git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main run_with_retries git_remote_cmd -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main
else else
run_with_retries git push origin HEAD:main run_with_retries git_remote_cmd push origin HEAD:main
fi fi
git branch -f main HEAD >/dev/null 2>&1 || true git branch -f main HEAD >/dev/null 2>&1 || true
log_success "main 已创建并指向当前提交" log_success "main 已创建并指向当前提交"