当提交标签失败后,需要删除本地创建的标签

This commit is contained in:
Jeff
2026-04-27 10:56:53 +08:00
parent c05a8cc0e0
commit 52221ac116

View File

@@ -239,8 +239,26 @@ int HandleCreateTagInteractive()
if (strPushResult.Left(6).CompareNoCase(_T("fatal:")) == 0 || strPushResult.Left(5).CompareNoCase(_T("error")) == 0) if (strPushResult.Left(6).CompareNoCase(_T("fatal:")) == 0 || strPushResult.Left(5).CompareNoCase(_T("error")) == 0)
{ {
_tprintf(_T("警告: 推送标签到远程失败: %s\n"), strPushResult.GetString()); _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 else
{ {