#include "ChangedDlg.h"\r
#include "SendMailDlg.h"\r
#include "SVNProgressDlg.h"\r
+#include "PushDlg.h"\r
\r
CAppUtils::CAppUtils(void)\r
{\r
return true;\r
}\r
return false;\r
-}
\ No newline at end of file
+}\r
+int CAppUtils::GetLogOutputEncode()\r
+{\r
+ CString cmd,output;\r
+ int start=0;\r
+ cmd=_T("git.exe config i18n.logOutputEncoding");\r
+ if(g_Git.Run(cmd,&output,CP_ACP))\r
+ {\r
+ cmd=_T("git.exe config i18n.commitencoding");\r
+ if(g_Git.Run(cmd,&output,CP_ACP))\r
+ return CP_UTF8;\r
+ \r
+ int start=0;\r
+ output=output.Tokenize(_T("\n"),start);\r
+ return CUnicodeUtils::GetCPCode(output); \r
+\r
+ }else\r
+ {\r
+ output=output.Tokenize(_T("\n"),start);\r
+ return CUnicodeUtils::GetCPCode(output);\r
+ }\r
+}\r
+int CAppUtils::SaveCommitUnicodeFile(CString &filename, CString &message)\r
+{\r
+ CFile file(filename,CFile::modeReadWrite|CFile::modeCreate );\r
+ CString cmd,output;\r
+ int cp=CP_UTF8;\r
+\r
+ cmd=_T("git.exe config i18n.commitencoding");\r
+ if(g_Git.Run(cmd,&output,CP_ACP))\r
+ cp=CP_UTF8;\r
+ \r
+ int start=0;\r
+ output=output.Tokenize(_T("\n"),start);\r
+ cp=CUnicodeUtils::GetCPCode(output); \r
+\r
+ int len=message.GetLength();\r
+\r
+ char * buf;\r
+ buf = new char[len*4 + 4];\r
+ SecureZeroMemory(buf, (len*4 + 4));\r
+\r
+ int lengthIncTerminator = WideCharToMultiByte(cp, 0, message, -1, buf, len*4, NULL, NULL);\r
+\r
+ file.Write(buf,lengthIncTerminator-1);\r
+ file.Close();\r
+ delete buf;\r
+ return 0;\r
+}\r
+\r
+bool CAppUtils::Push()\r
+{\r
+ CPushDlg dlg;\r
+// dlg.m_Directory=this->orgCmdLinePath.GetWinPathString();\r
+ if(dlg.DoModal()==IDOK)\r
+ {\r
+// CString dir=dlg.m_Directory;\r
+// CString url=dlg.m_URL;\r
+ CString cmd;\r
+ CString force;\r
+ CString tags;\r
+ CString thin;\r
+\r
+ if(dlg.m_bAutoLoad)\r
+ {\r
+ CAppUtils::LaunchPAgent(NULL,&dlg.m_URL);\r
+ }\r
+\r
+ if(dlg.m_bPack)\r
+ thin=_T("--thin");\r
+ if(dlg.m_bTags)\r
+ tags=_T("--tags");\r
+ if(dlg.m_bForce)\r
+ force=_T("--force");\r
+ \r
+ cmd.Format(_T("git.exe push %s %s %s \"%s\" %s"),\r
+ thin,tags,force,\r
+ dlg.m_URL,\r
+ dlg.m_BranchSourceName);\r
+ if (!dlg.m_BranchRemoteName.IsEmpty())\r
+ {\r
+ cmd += _T(":") + dlg.m_BranchRemoteName;\r
+ }\r
+\r
+ CProgressDlg progress;\r
+ progress.m_GitCmd=cmd;\r
+ if(progress.DoModal()==IDOK)\r
+ return TRUE;\r
+ \r
+ }\r
+ return FALSE;\r
+}\r
+\r
+bool CAppUtils::CreateMultipleDirectory(CString& szPath)\r
+{\r
+ CString strDir(szPath);\r
+ if (strDir.GetAt(strDir.GetLength()-1)!=_T('\\'))\r
+ {\r
+ strDir.AppendChar(_T('\\'));\r
+ }\r
+ std::vector<CString> vPath;\r
+ CString strTemp;\r
+ bool bSuccess = false;\r
+ \r
+ for (int i=0;i<strDir.GetLength();++i)\r
+ {\r
+ if (strDir.GetAt(i) != _T('\\')) \r
+ {\r
+ strTemp.AppendChar(strDir.GetAt(i));\r
+ }\r
+ else \r
+ {\r
+ vPath.push_back(strTemp);\r
+ strTemp.AppendChar(_T('\\'));\r
+ }\r
+ }\r
+\r
+ std::vector<CString>::const_iterator vIter;\r
+ for (vIter = vPath.begin(); vIter != vPath.end(); vIter++) \r
+ {\r
+ bSuccess = CreateDirectory(*vIter, NULL) ? true : false; \r
+ }\r
+\r
+ return bSuccess;\r
+}\r