OSDN Git Service

Add bugtraq to support commit dialog bug track.
authorFrank Li <lznuaa@gmail.com>
Sun, 31 May 2009 10:03:28 +0000 (18:03 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 31 May 2009 10:03:28 +0000 (18:03 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/CommitDlg.cpp
src/TortoiseProc/ProjectProperties.cpp
src/TortoiseProc/ProjectProperties.h

index 45c8beb..fb5a5d0 100644 (file)
@@ -462,6 +462,19 @@ void CCommitDlg::OnOK()
        //      cmd.Format(_T("git.exe reset -- %s"),uncheckedfiles);\r
        //      g_Git.Run(cmd,&out);\r
        //}\r
+       \r
+       m_sBugID.Trim();\r
+       if (!m_sBugID.IsEmpty())\r
+       {\r
+               m_sBugID.Replace(_T(", "), _T(","));\r
+               m_sBugID.Replace(_T(" ,"), _T(","));\r
+               CString sBugID = m_ProjectProperties.sMessage;\r
+               sBugID.Replace(_T("%BUGID%"), m_sBugID);\r
+               if (m_ProjectProperties.bAppend)\r
+                       m_sLogMessage += _T("\n") + sBugID + _T("\n");\r
+               else\r
+                       m_sLogMessage = sBugID + _T("\n") + m_sLogMessage;\r
+       }\r
 \r
        BOOL bCloseCommitDlg=true;\r
        //if(checkedfiles.GetLength()>0)\r
@@ -620,18 +633,7 @@ void CCommitDlg::OnOK()
        if (!GetDlgItem(IDC_KEEPLISTS)->IsWindowEnabled())\r
                m_bKeepChangeList = FALSE;\r
        InterlockedExchange(&m_bBlock, FALSE);\r
-       m_sBugID.Trim();\r
-       if (!m_sBugID.IsEmpty())\r
-       {\r
-               m_sBugID.Replace(_T(", "), _T(","));\r
-               m_sBugID.Replace(_T(" ,"), _T(","));\r
-               CString sBugID = m_ProjectProperties.sMessage;\r
-               sBugID.Replace(_T("%BUGID%"), m_sBugID);\r
-               if (m_ProjectProperties.bAppend)\r
-                       m_sLogMessage += _T("\n") + sBugID + _T("\n");\r
-               else\r
-                       m_sLogMessage = sBugID + _T("\n") + m_sLogMessage;\r
-       }\r
+\r
        m_History.AddEntry(m_sLogMessage);\r
        m_History.Save();\r
 \r
index 4510fdf..75d6687 100644 (file)
@@ -23,6 +23,7 @@
 //#include "GitProperties.h"\r
 #include "TGitPath.h"\r
 #include <regex>\r
+#include "git.h"\r
 \r
 using namespace std;\r
 \r
@@ -56,8 +57,68 @@ BOOL ProjectProperties::ReadPropsPathList(const CTGitPathList& pathList)
        return FALSE;\r
 }\r
 \r
+BOOL ProjectProperties::GetStringProps(CString &prop,TCHAR *key,bool bRemoveCR)\r
+{\r
+       CString cmd,output;\r
+       output.Empty();\r
+\r
+       cmd.Format(_T("git.exe config %s"),key);\r
+       int start = 0;\r
+       if(g_Git.Run(cmd,&output,CP_ACP))\r
+       {\r
+               return FALSE;\r
+       }\r
+       if(bRemoveCR)\r
+               prop = output.Tokenize(_T("\n"),start); \r
+       else\r
+               prop = output;\r
+\r
+       return TRUE;\r
+\r
+}\r
+\r
+BOOL ProjectProperties::GetBOOLProps(BOOL &b,TCHAR *key)\r
+{\r
+       CString str,low;\r
+       if(!GetStringProps(str,key))\r
+               return FALSE;\r
+\r
+       low=str.MakeLower();\r
+       if(low == _T("true"))\r
+               b=true;\r
+       else\r
+               b=false;\r
+\r
+       return true;\r
+\r
+}\r
 BOOL ProjectProperties::ReadProps(CTGitPath path)\r
 {\r
+       CString sPropVal;\r
+\r
+       GetStringProps(this->sLabel,BUGTRAQPROPNAME_LABEL);\r
+       GetStringProps(this->sMessage,BUGTRAQPROPNAME_MESSAGE);\r
+\r
+       GetBOOLProps(this->bWarnIfNoIssue,BUGTRAQPROPNAME_WARNIFNOISSUE);\r
+       GetBOOLProps(this->bNumber,BUGTRAQPROPNAME_NUMBER);\r
+       GetBOOLProps(this->bAppend,BUGTRAQPROPNAME_APPEND);\r
+\r
+       GetStringProps(sPropVal,BUGTRAQPROPNAME_LOGREGEX,false);\r
+\r
+       sCheckRe = sPropVal;\r
+       if (sCheckRe.Find('\n')>=0)\r
+       {\r
+               sBugIDRe = sCheckRe.Mid(sCheckRe.Find('\n')).Trim();\r
+               sCheckRe = sCheckRe.Left(sCheckRe.Find('\n')).Trim();\r
+       }\r
+       if (!sCheckRe.IsEmpty())\r
+       {\r
+               sCheckRe = sCheckRe.Trim();\r
+       }\r
+       return TRUE;\r
+\r
+\r
+#if 0\r
        BOOL bFoundBugtraqLabel = FALSE;\r
        BOOL bFoundBugtraqMessage = FALSE;\r
        BOOL bFoundBugtraqNumber = FALSE;\r
@@ -80,7 +141,7 @@ BOOL ProjectProperties::ReadProps(CTGitPath path)
 \r
        if (!path.IsDirectory())\r
                path = path.GetContainingDirectory();\r
-#if 0          \r
+               \r
        for (;;)\r
        {\r
                GitProperties props(path, GitRev::REV_WC, false);\r
index 0f0bf95..31ebca8 100644 (file)
 #include "TGitPath.h"\r
 using namespace std;\r
 \r
-#define BUGTRAQPROPNAME_LABEL             _T("bugtraq:label")\r
-#define BUGTRAQPROPNAME_MESSAGE           _T("bugtraq:message")\r
-#define BUGTRAQPROPNAME_NUMBER            _T("bugtraq:number")\r
-#define BUGTRAQPROPNAME_LOGREGEX                 _T("bugtraq:logregex")\r
-#define BUGTRAQPROPNAME_URL               _T("bugtraq:url")\r
-#define BUGTRAQPROPNAME_WARNIFNOISSUE     _T("bugtraq:warnifnoissue")\r
-#define BUGTRAQPROPNAME_APPEND               _T("bugtraq:append")\r
-\r
-#define PROJECTPROPNAME_LOGTEMPLATE              _T("tsvn:logtemplate")\r
-#define PROJECTPROPNAME_LOGWIDTHLINE     _T("tsvn:logwidthmarker")\r
-#define PROJECTPROPNAME_LOGMINSIZE               _T("tsvn:logminsize")\r
-#define PROJECTPROPNAME_LOCKMSGMINSIZE   _T("tsvn:lockmsgminsize")\r
-#define PROJECTPROPNAME_LOGFILELISTLANG          _T("tsvn:logfilelistenglish")\r
-#define PROJECTPROPNAME_LOGSUMMARY               _T("tsvn:logsummary")\r
-#define PROJECTPROPNAME_PROJECTLANGUAGE   _T("tsvn:projectlanguage")\r
-#define PROJECTPROPNAME_USERFILEPROPERTY  _T("tsvn:userfileproperties")\r
-#define PROJECTPROPNAME_USERDIRPROPERTY   _T("tsvn:userdirproperties")\r
-#define PROJECTPROPNAME_AUTOPROPS                _T("tsvn:autoprops")\r
-\r
-#define PROJECTPROPNAME_WEBVIEWER_REV     _T("webviewer:revision")\r
-#define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer:pathrevision")\r
+#define BUGTRAQPROPNAME_LABEL             _T("bugtraq.label")\r
+#define BUGTRAQPROPNAME_MESSAGE           _T("bugtraq.message")\r
+#define BUGTRAQPROPNAME_NUMBER            _T("bugtraq.number")\r
+#define BUGTRAQPROPNAME_LOGREGEX                 _T("bugtraq.logregex")\r
+#define BUGTRAQPROPNAME_URL               _T("bugtraq.url")\r
+#define BUGTRAQPROPNAME_WARNIFNOISSUE     _T("bugtraq.warnifnoissue")\r
+#define BUGTRAQPROPNAME_APPEND               _T("bugtraq.append")\r
+\r
+#define PROJECTPROPNAME_LOGTEMPLATE              _T("tsvn.logtemplate")\r
+#define PROJECTPROPNAME_LOGWIDTHLINE     _T("tsvn.logwidthmarker")\r
+#define PROJECTPROPNAME_LOGMINSIZE               _T("tsvn.logminsize")\r
+#define PROJECTPROPNAME_LOCKMSGMINSIZE   _T("tsvn.lockmsgminsize")\r
+#define PROJECTPROPNAME_LOGFILELISTLANG          _T("tsvn.logfilelistenglish")\r
+#define PROJECTPROPNAME_LOGSUMMARY               _T("tsvn.logsummary")\r
+#define PROJECTPROPNAME_PROJECTLANGUAGE   _T("tsvn.projectlanguage")\r
+#define PROJECTPROPNAME_USERFILEPROPERTY  _T("tsvn.userfileproperties")\r
+#define PROJECTPROPNAME_USERDIRPROPERTY   _T("tsvn.userdirproperties")\r
+#define PROJECTPROPNAME_AUTOPROPS                _T("tsvn.autoprops")\r
+\r
+#define PROJECTPROPNAME_WEBVIEWER_REV     _T("webviewer.revision")\r
+#define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")\r
 \r
 class CTSVNPathList;\r
 struct svn_config_t;\r
@@ -65,6 +65,8 @@ public:
         * \param path path to a file or a folder\r
         */\r
        BOOL ReadProps(CTGitPath path);\r
+       BOOL GetStringProps(CString &prop,TCHAR *key,bool bRemoveCR=true);\r
+       BOOL GetBOOLProps(BOOL &b, TCHAR*key);\r
        /**\r
         * Reads the properties from all paths found in a path list.\r
         * This method calls ReadProps() for each path .\r