From 52221ac1165a71cde2a584572ef99ff933548f41 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 27 Apr 2026 10:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E6=8F=90=E4=BA=A4=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C=E9=9C=80=E8=A6=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9C=AC=E5=9C=B0=E5=88=9B=E5=BB=BA=E7=9A=84=E6=A0=87?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GitVer/GitVer_tag.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/GitVer/GitVer_tag.cpp b/GitVer/GitVer_tag.cpp index dc57b2d..a5572b6 100644 --- a/GitVer/GitVer_tag.cpp +++ b/GitVer/GitVer_tag.cpp @@ -239,8 +239,26 @@ int HandleCreateTagInteractive() if (strPushResult.Left(6).CompareNoCase(_T("fatal:")) == 0 || strPushResult.Left(5).CompareNoCase(_T("error")) == 0) { _tprintf(_T("警告: 推送标签到远程失败: %s\n"), strPushResult.GetString()); - // 这里可选择返回非零表示失败,或只是告警后继续返回成功 - return 36; + + // 推送失败:尝试删除本地标签,避免残留 + CString strDeleteCmd; + strDeleteCmd.Format(_T("cmd /c git tag -d %s"), QuoteCmdArg(strNewTag).GetString()); + CString strDeleteResult = StartProcess(NULL, strDeleteCmd.GetBuffer(), lpRepoPath); + strDeleteCmd.ReleaseBuffer(); + strDeleteResult.Trim(); + + if (strDeleteResult.Left(6).CompareNoCase(_T("fatal:")) == 0 || strDeleteResult.Left(5).CompareNoCase(_T("error")) == 0) + { + _tprintf(_T("错误: 推送失败,且删除本地标签失败: %s\n"), strDeleteResult.GetString()); + // 返回错误码 36 表示推送失败(删除也失败) + return 36; + } + else + { + _tprintf(_T("已删除本地标签: %s\n"), strNewTag.GetString()); + // 返回错误码 36 表示推送失败,但本地标签已清理 + return 36; + } } else {