更新: 1 个文件 - 2026-03-17 23:10:49
这个提交包含在:
@@ -100,7 +100,7 @@ ensure_remote_repo() {
|
||||
fi
|
||||
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
log_error "远程仓库不存在,且未提供 GITEA_TOKEN,无法自动创建"
|
||||
log_error "远程仓库不可达或不存在,且未提供 GITEA_TOKEN,无法自动创建"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -156,8 +156,6 @@ init_repo() {
|
||||
git remote add origin "$(repo_git_url)"
|
||||
log_success "远程仓库已添加"
|
||||
fi
|
||||
|
||||
ensure_remote_repo
|
||||
|
||||
# 凭证处理:
|
||||
# 默认不在仓库脚本中写入真实凭证。
|
||||
@@ -236,17 +234,20 @@ push_changes() {
|
||||
|
||||
if [ "$AUTO_PUSH_MAIN" = "1" ]; then
|
||||
if git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
|
||||
git fetch origin main >/dev/null 2>&1 || true
|
||||
if git merge-base --is-ancestor FETCH_HEAD HEAD; then
|
||||
if [ -n "$GITEA_TOKEN" ]; then
|
||||
git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main
|
||||
if git 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 [ -n "$GITEA_TOKEN" ]; then
|
||||
git -c http.extraHeader="Authorization: token ${GITEA_TOKEN}" push origin HEAD:main
|
||||
else
|
||||
git push origin HEAD:main
|
||||
fi
|
||||
git branch -f main HEAD >/dev/null 2>&1 || true
|
||||
log_success "main 已快进到当前提交"
|
||||
else
|
||||
git push origin HEAD:main
|
||||
log_warning "origin/main 不是当前 HEAD 的祖先,跳过 main 快进推送"
|
||||
fi
|
||||
git branch -f main HEAD >/dev/null 2>&1 || true
|
||||
log_success "main 已快进到当前提交"
|
||||
else
|
||||
log_warning "origin/main 不是当前 HEAD 的祖先,跳过 main 快进推送"
|
||||
log_warning "刷新 origin/main 失败,跳过 main 快进推送"
|
||||
fi
|
||||
else
|
||||
if [ -n "$GITEA_TOKEN" ]; then
|
||||
@@ -328,6 +329,7 @@ case "${1:-}" in
|
||||
;;
|
||||
--ensure)
|
||||
init_repo
|
||||
ensure_remote_repo
|
||||
;;
|
||||
--status)
|
||||
show_status
|
||||
|
||||
在新工单中引用
屏蔽一个用户