1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008,2011-2012 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #define BUGTRAQPROPNAME_LABEL _T("bugtraq.label")
28 #define BUGTRAQPROPNAME_MESSAGE _T("bugtraq.message")
29 #define BUGTRAQPROPNAME_NUMBER _T("bugtraq.number")
30 #define BUGTRAQPROPNAME_LOGREGEX _T("bugtraq.logregex")
31 #define BUGTRAQPROPNAME_URL _T("bugtraq.url")
32 #define BUGTRAQPROPNAME_WARNIFNOISSUE _T("bugtraq.warnifnoissue")
33 #define BUGTRAQPROPNAME_APPEND _T("bugtraq.append")
35 #define PROJECTPROPNAME_LOGTEMPLATE _T("tsvn.logtemplate")
36 #define PROJECTPROPNAME_LOGWIDTHLINE _T("tsvn.logwidthmarker")
37 #define PROJECTPROPNAME_LOGMINSIZE _T("tsvn.logminsize")
38 #define PROJECTPROPNAME_LOCKMSGMINSIZE _T("tsvn.lockmsgminsize")
39 #define PROJECTPROPNAME_LOGFILELISTLANG _T("tsvn.logfilelistenglish")
40 #define PROJECTPROPNAME_PROJECTLANGUAGE _T("tsvn.projectlanguage")
41 #define PROJECTPROPNAME_USERFILEPROPERTY _T("tsvn.userfileproperties")
42 #define PROJECTPROPNAME_USERDIRPROPERTY _T("tsvn.userdirproperties")
44 #define PROJECTPROPNAME_WEBVIEWER_REV _T("webviewer.revision")
45 #define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")
48 * \ingroup TortoiseProc
49 * Provides methods for retrieving information about bug/issue trackers
50 * associated with a Subversion repository/working copy and other project
53 class ProjectProperties
56 ProjectProperties(void);
57 ~ProjectProperties(void);
60 * Reads the properties from a path. If the path is a file
61 * then the properties are read from the parent folder of that file.
62 * \param path path to a file or a folder
64 BOOL
ReadProps(CTGitPath path
);
65 static BOOL
GetStringProps(CString
&prop
,TCHAR
*key
,bool bRemoveCR
=true);
66 static BOOL
GetBOOLProps(BOOL
&b
, TCHAR
*key
);
68 * Reads the properties from all paths found in a path list.
69 * This method calls ReadProps() for each path .
70 * \param list of paths
72 BOOL
ReadPropsPathList(const CTGitPathList
& pathList
);
75 * Searches for the BugID inside a log message. If one is found,
76 * the method returns TRUE. The rich edit control is used to set
77 * the CFE_LINK effect on the BugID's.
78 * \param msg the log message
79 * \param pWnd Pointer to a rich edit control
82 std::vector
<CHARRANGE
> FindBugIDPositions(const CString
& msg
);
84 BOOL
FindBugID(const CString
& msg
, CWnd
* pWnd
);
86 CString
FindBugID(const CString
& msg
);
87 std::set
<CString
> FindBugIDs(const CString
& msg
);
90 * Check whether calling \ref FindBugID or \ref FindBugIDPositions
91 * is worthwhile. If the result is @a false, those functions would
92 * return empty strings or sets, respectively.
94 bool MightContainABugID();
97 * Searches for the BugID inside a log message. If one is found,
98 * that BugID is returned. If none is found, an empty string is returned.
99 * The \c msg is trimmed off the BugID.
101 CString
GetBugIDFromLog(CString
& msg
);
104 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
105 * functions checks if the bug ID doesn't contain any non-number chars in it.
107 BOOL
CheckBugID(const CString
& sID
);
110 * Checks if the log message \c sMessage contains a bug ID. This is done by
111 * using the bugtraq:checkre property.
113 BOOL
HasBugID(const CString
& sMessage
);
116 * Returns the URL pointing to the Issue in the issue tracker. The URL is
117 * created from the bugtraq:url property and the BugID found in the log message.
118 * \param msg the BugID extracted from the log message
120 CString
GetBugIDUrl(const CString
& sBugID
);
122 /** replaces bNumer: a regular expression string to check the validity of
123 * the entered bug ID. */
124 const CString
& GetCheckRe() const {return sCheckRe
;}
125 void SetCheckRe(const CString
& s
) {sCheckRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
127 /** used to extract the bug ID from the string matched by sCheckRe */
128 const CString
& GetBugIDRe() const {return sBugIDRe
;}
129 void SetBugIDRe(const CString
& s
) {sBugIDRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
132 /** The label to show in the commit dialog where the issue number/bug id
133 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
136 /** The message string to add below the log message the user entered.
137 * It must contain the string "%BUGID%" which gets replaced by the client
138 * with the issue number / bug id the user entered. */
141 /** If this is set, then the bug-id / issue number must be a number, no text */
144 /** replaces bNumer: a regular expression string to check the validity of
145 * the entered bug ID. */
148 /** used to extract the bug ID from the string matched by sCheckRe */
151 /** The url pointing to the issue tracker. If the url contains the string
152 * "%BUGID% the client has to replace it with the issue number / bug id
153 * the user entered. */
156 /** If set to TRUE, show a warning dialog if the user forgot to enter
157 * an issue number in the commit dialog. */
160 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
161 log message instead of at the bottom. Default is TRUE */
164 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
166 CString sProviderUuid
;
168 /** the parameters passed to the COM bugtraq provider which implements the
169 IBugTraqProvider interface */
170 CString sProviderParams
;
172 /** The number of chars the width marker should be shown at. If the property
173 * is not set, then this value is 80 by default. */
176 /** The template to use for log messages. */
177 CString sLogTemplate
;
179 /** Minimum size a log message must have in chars */
182 /** Minimum size a lock message must have in chars */
185 /** TRUE if the file list to be inserted in the commit dialog should be in
186 * English and not in the localized language. Default is TRUE */
187 BOOL bFileListInEnglish
;
189 /** The language identifier this project uses for log messages. */
190 LONG lProjectLanguage
;
192 /** holds user defined properties for files. */
195 /** holds user defined properties for directories. */
198 /** The url pointing to the web viewer. The string %REVISION% is replaced
199 * with the revision number, "HEAD", or a date */
200 CString sWebViewerRev
;
202 /** The url pointing to the web viewer. The string %REVISION% is replaced
203 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
204 * with the path relative to the repository root, e.g. "/trunk/src/file" */
205 CString sWebViewerPathRev
;
208 * A regex string to extract revisions from a log message.
210 CString sLogRevRegex
;
215 * Constructing regex objects is expensive. Therefore, cache them here.
217 void AutoUpdateRegex();
219 bool CheckStringProp(CString
& s
, const std::string
& propname
, const CString
& propval
, LPCSTR prop
);
221 bool regExNeedUpdate
;
222 std::tr1::wregex regCheck
;
223 std::tr1::wregex regBugID
;
225 int nBugIdPos
; ///< result of sMessage.Find(L"%BUGID%");
228 friend class PropTest
;