hash=hash.Left(40);\r
\r
return hash == base;\r
+}\r
+\r
+unsigned int CGit::Hash2int(CString &hash)\r
+{\r
+ int ret=0;\r
+ for(int i=0;i<8;i++)\r
+ {\r
+ ret =ret <<4;\r
+ if(hash[i]>=_T('a'))\r
+ ret |= (hash[i]-_T('a')+10)&0xFF;\r
+ else if(hash[i]>=_T('A'))\r
+ ret |= (hash[i]-_T('A')+10)&0xFF;\r
+ else\r
+ ret |= (hash[i]-_T('0'))&0xFF; \r
+ \r
+ }\r
+ return ret;\r
}
\ No newline at end of file
static BOOL CheckMsysGitDir();\r
static CString ms_LastMsysGitDir; // the last msysgitdir added to the path, blank if none\r
static int m_LogEncode;\r
+ unsigned int Hash2int(CString &hash);\r
// static CString m_MsysGitPath;\r
\r
PROCESS_INFORMATION m_CurrentGitPi;\r
#include "ShellUpdater.h"\r
#include "Commands/PushCommand.h"\r
#include "PatchViewDlg.h"\r
+#include "COMError.h"\r
\r
#ifdef _DEBUG\r
#define new DEBUG_NEW\r
return;\r
}\r
\r
+ m_ListCtrl.WriteCheckedNamesToPathList(m_selectedPathList);\r
#if 0\r
CRegDWORD regUnversionedRecurse (_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE);\r
if (!(DWORD)regUnversionedRecurse)\r
//std::set<CString> checkedLists;\r
//std::set<CString> uncheckedLists;\r
\r
+ // now let the bugtraq plugin check the commit message\r
+ CComPtr<IBugTraqProvider2> pProvider2 = NULL;\r
+ if (m_BugTraqProvider)\r
+ {\r
+ HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);\r
+ if (SUCCEEDED(hr))\r
+ {\r
+ BSTR temp = NULL;\r
+ CString common = g_Git.m_CurrentDir;\r
+ BSTR repositoryRoot = common.AllocSysString();\r
+ BSTR parameters = m_bugtraq_association.GetParameters().AllocSysString();\r
+ BSTR commonRoot = SysAllocString(m_pathList.GetCommonRoot().GetDirectory().GetWinPath());\r
+ BSTR commitMessage = m_sLogMessage.AllocSysString();\r
+ SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0, m_selectedPathList.GetCount());\r
+\r
+ for (LONG index = 0; index < m_selectedPathList.GetCount(); ++index)\r
+ SafeArrayPutElement(pathList, &index, m_selectedPathList[index].GetGitPathString().AllocSysString());\r
+\r
+ if (FAILED(hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, repositoryRoot, commonRoot, pathList, commitMessage, &temp)))\r
+ {\r
+ COMError ce(hr);\r
+ CString sErr;\r
+ sErr.Format(IDS_ERR_FAILEDISSUETRACKERCOM, m_bugtraq_association.GetProviderName(), ce.GetMessageAndDescription().c_str());\r
+ CMessageBox::Show(m_hWnd, sErr, _T("TortoiseSVN"), MB_ICONERROR);\r
+ }\r
+ else\r
+ {\r
+ CString sError = temp;\r
+ if (!sError.IsEmpty())\r
+ {\r
+ CMessageBox::Show(m_hWnd, sError, _T("TortoiseSVN"), MB_ICONERROR);\r
+ return;\r
+ }\r
+ SysFreeString(temp);\r
+ }\r
+ }\r
+ }\r
+\r
//CString checkedfiles;\r
//CString uncheckedfiles;\r
\r
//User pressed 'Push' button after successful commit.\r
m_bPushAfterCommit=true;\r
}\r
-\r
+ \r
CFile::Remove(tempfile);\r
+\r
+ if (m_BugTraqProvider && progress.m_GitStatus == 0)\r
+ {\r
+ CComPtr<IBugTraqProvider2> pProvider = NULL;\r
+ HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);\r
+ if (SUCCEEDED(hr))\r
+ {\r
+ BSTR commonRoot = SysAllocString(g_Git.m_CurrentDir);\r
+ SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0,this->m_selectedPathList.GetCount());\r
+\r
+ for (LONG index = 0; index < m_selectedPathList.GetCount(); ++index)\r
+ SafeArrayPutElement(pathList, &index, m_selectedPathList[index].GetGitPathString().AllocSysString());\r
+\r
+ BSTR logMessage = m_sLogMessage.AllocSysString();\r
+\r
+ CString hash=g_Git.GetHash(CString(_T("HEAD")));\r
+ LONG version = g_Git.Hash2int(hash);\r
+\r
+ BSTR temp = NULL;\r
+ if (FAILED(hr = pProvider->OnCommitFinished(GetSafeHwnd(), \r
+ commonRoot,\r
+ pathList,\r
+ logMessage,\r
+ (LONG)version,\r
+ &temp)))\r
+ {\r
+ CString sErr = temp;\r
+ if (!sErr.IsEmpty())\r
+ CMessageBox::Show(NULL,(sErr),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+ else\r
+ {\r
+ COMError ce(hr);\r
+ sErr.Format(IDS_ERR_FAILEDISSUETRACKERCOM, ce.GetSource().c_str(), ce.GetMessageAndDescription().c_str());\r
+ CMessageBox::Show(NULL,(sErr),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+ }\r
+ }\r
+\r
+ SysFreeString(temp);\r
+ }\r
+ }\r
+ \r
}else\r
{\r
CMessageBox::Show(this->m_hWnd, IDS_ERROR_NOTHING_COMMIT, IDS_COMMIT_FINISH, MB_OK | MB_ICONINFORMATION);\r
//save only the files the user has checked into the temporary file\r
m_ListCtrl.WriteCheckedNamesToPathList(m_pathList);\r
}\r
- m_ListCtrl.WriteCheckedNamesToPathList(m_selectedPathList);\r
+ \r
// the item count is used in the progress dialog to show the overall commit\r
// progress.\r
// deleted items only send one notification event, all others send two\r
--- /dev/null
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2009 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#include "StdAfx.h"\r
+#include "COMError.h"\r
+\r
+#pragma comment(lib, "Rpcrt4.lib")\r
+\r
+COMError::COMError(HRESULT hr)\r
+{\r
+ _com_error e(hr);\r
+ IErrorInfo *pIErrorInfo = NULL;\r
+ GetErrorInfo(0, &pIErrorInfo);\r
+\r
+ if (pIErrorInfo == NULL)\r
+ {\r
+ e = _com_error(hr);\r
+ message = e.ErrorMessage();\r
+ }\r
+ else\r
+ {\r
+ e = _com_error(hr, pIErrorInfo);\r
+ message = e.ErrorMessage();\r
+ IErrorInfo *ptrIErrorInfo = e.ErrorInfo();\r
+ if (ptrIErrorInfo != NULL)\r
+ {\r
+ // IErrorInfo Interface located\r
+ description = (WCHAR *)e.Description();\r
+ source = (WCHAR *)e.Source();\r
+ GUID tmpGuid = e.GUID();\r
+ RPC_WSTR guidStr = NULL;\r
+ // must link in Rpcrt4.lib for UuidToString\r
+ UuidToString(&tmpGuid, &guidStr);\r
+ uuid = (WCHAR*)guidStr;\r
+ RpcStringFree(&guidStr);\r
+\r
+ ptrIErrorInfo->Release();\r
+ }\r
+ }\r
+}\r
+\r
+COMError::~COMError()\r
+{\r
+\r
+}
\ No newline at end of file
--- /dev/null
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2009 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+\r
+class COMError\r
+{\r
+public:\r
+ COMError(HRESULT hr);\r
+ virtual ~COMError();\r
+\r
+ std::wstring GetMessage() {return message;}\r
+ std::wstring GetDescription() {return description;}\r
+ std::wstring GetMessageAndDescription() {return message + _T("\n") + description;}\r
+ std::wstring GetSource() {return source;}\r
+ std::wstring GetUUID() {return uuid;}\r
+\r
+private:\r
+ std::wstring message;\r
+ std::wstring description;\r
+ std::wstring source;\r
+ std::wstring uuid;\r
+};\r
>\r
</File>\r
<File\r
+ RelativePath=".\COMError.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\CSmtp.cpp"\r
>\r
<FileConfiguration\r