1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009,2011-2013 - TortoiseGit
4 // Copyright (C) 2003-2008,2011-2012 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #define BUGTRAQPROPNAME_LABEL _T("bugtraq.label")
25 #define BUGTRAQPROPNAME_MESSAGE _T("bugtraq.message")
26 #define BUGTRAQPROPNAME_NUMBER _T("bugtraq.number")
27 #define BUGTRAQPROPNAME_LOGREGEX _T("bugtraq.logregex")
28 #define BUGTRAQPROPNAME_URL _T("bugtraq.url")
29 #define BUGTRAQPROPNAME_WARNIFNOISSUE _T("bugtraq.warnifnoissue")
30 #define BUGTRAQPROPNAME_APPEND _T("bugtraq.append")
31 #define BUGTRAQPROPNAME_PROVIDERUUID _T("bugtraq.provideruuid")
32 #define BUGTRAQPROPNAME_PROVIDERUUID64 _T("bugtraq.provideruuid64")
33 #define BUGTRAQPROPNAME_PROVIDERPARAMS _T("bugtraq.providerparams")
35 #define PROJECTPROPNAME_LOGTEMPLATE _T("tsvn.logtemplate")
36 #define PROJECTPROPNAME_LOGWIDTHLINE _T("tgit.logwidthmarker")
37 #define PROJECTPROPNAME_LOGMINSIZE _T("tgit.logminsize")
38 #define PROJECTPROPNAME_LOGFILELISTLANG _T("tsvn.logfilelistenglish")
39 #define PROJECTPROPNAME_PROJECTLANGUAGE _T("tgit.projectlanguage")
40 #define PROJECTPROPNAME_WARNNOSIGNEDOFFBY _T("tgit.warnnosignedoffby")
42 #define PROJECTPROPNAME_WEBVIEWER_REV _T("webviewer.revision")
43 #define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")
46 * \ingroup TortoiseProc
47 * Provides methods for retrieving information about bug/issue trackers
48 * associated with a Subversion repository/working copy and other project
51 class ProjectProperties
54 ProjectProperties(void);
55 ~ProjectProperties(void);
58 * Reads the properties from a path. If the path is a file
59 * then the properties are read from the parent folder of that file.
60 * \param path path to a file or a folder
62 BOOL
ReadProps(CTGitPath path
);
65 int GetStringProps(CString
&prop
, const CString
&key
);
66 int GetBOOLProps(BOOL
&b
, const CString
&key
);
70 * Reads the properties from all paths found in a path list.
71 * This method calls ReadProps() for each path .
72 * \param list of paths
74 int ReadPropsPathList(const CTGitPathList
& pathList
);
77 * Searches for the BugID inside a log message. If one is found,
78 * the method returns TRUE. The rich edit control is used to set
79 * the CFE_LINK effect on the BugID's.
80 * \param msg the log message
81 * \param pWnd Pointer to a rich edit control
84 std::vector
<CHARRANGE
> FindBugIDPositions(const CString
& msg
);
86 BOOL
FindBugID(const CString
& msg
, CWnd
* pWnd
);
88 CString
FindBugID(const CString
& msg
);
89 std::set
<CString
> FindBugIDs(const CString
& msg
);
92 * Check whether calling \ref FindBugID or \ref FindBugIDPositions
93 * is worthwhile. If the result is @a false, those functions would
94 * return empty strings or sets, respectively.
96 bool MightContainABugID();
99 * Searches for the BugID inside a log message. If one is found,
100 * that BugID is returned. If none is found, an empty string is returned.
101 * The \c msg is trimmed off the BugID.
103 CString
GetBugIDFromLog(CString
& msg
);
106 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
107 * functions checks if the bug ID doesn't contain any non-number chars in it.
109 BOOL
CheckBugID(const CString
& sID
);
112 * Checks if the log message \c sMessage contains a bug ID. This is done by
113 * using the bugtraq:checkre property.
115 BOOL
HasBugID(const CString
& sMessage
);
118 * Returns the URL pointing to the Issue in the issue tracker. The URL is
119 * created from the bugtraq:url property and the BugID found in the log message.
120 * \param msg the BugID extracted from the log message
122 CString
GetBugIDUrl(const CString
& sBugID
);
124 /** replaces bNumer: a regular expression string to check the validity of
125 * the entered bug ID. */
126 const CString
& GetCheckRe() const {return sCheckRe
;}
127 void SetCheckRe(const CString
& s
) {sCheckRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
129 /** used to extract the bug ID from the string matched by sCheckRe */
130 const CString
& GetBugIDRe() const {return sBugIDRe
;}
131 void SetBugIDRe(const CString
& s
) {sBugIDRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
134 const CString
& GetProviderUUID() const { return (sProviderUuid64
.IsEmpty() ? sProviderUuid
: sProviderUuid64
); }
136 const CString
& GetProviderUUID() const { return (sProviderUuid
.IsEmpty() ? sProviderUuid64
: sProviderUuid
); }
140 /** The label to show in the commit dialog where the issue number/bug id
141 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
144 /** The message string to add below the log message the user entered.
145 * It must contain the string "%BUGID%" which gets replaced by the client
146 * with the issue number / bug id the user entered. */
149 /** If this is set, then the bug-id / issue number must be a number, no text */
152 /** replaces bNumer: a regular expression string to check the validity of
153 * the entered bug ID. */
156 /** used to extract the bug ID from the string matched by sCheckRe */
159 /** The url pointing to the issue tracker. If the url contains the string
160 * "%BUGID% the client has to replace it with the issue number / bug id
161 * the user entered. */
164 /** If set to TRUE, show a warning dialog if the user forgot to enter
165 * an issue number in the commit dialog. */
168 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
169 log message instead of at the bottom. Default is TRUE */
172 /** the parameters passed to the COM bugtraq provider which implements the
173 IBugTraqProvider interface */
174 CString sProviderParams
;
176 /** The number of chars the width marker should be shown at. If the property
177 * is not set, then this value is 80 by default. */
180 /** The template to use for log messages. */
181 CString sLogTemplate
;
183 /** Minimum size a log message must have in chars */
186 /** TRUE if the file list to be inserted in the commit dialog should be in
187 * English and not in the localized language. Default is TRUE */
188 BOOL bFileListInEnglish
;
190 /** The language identifier this project uses for log messages. */
191 LONG lProjectLanguage
;
193 /** The url pointing to the web viewer. The string %REVISION% is replaced
194 * with the revision number, "HEAD", or a date */
195 CString sWebViewerRev
;
197 /** The url pointing to the web viewer. The string %REVISION% is replaced
198 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
199 * with the path relative to the repository root, e.g. "/trunk/src/file" */
200 CString sWebViewerPathRev
;
202 BOOL bWarnNoSignedOffBy
;
205 * A regex string to extract revisions from a log message.
207 CString sLogRevRegex
;
209 git_config
*gitconfig
;
211 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
213 CString sProviderUuid
;
214 CString sProviderUuid64
;
217 * Constructing regex objects is expensive. Therefore, cache them here.
219 void AutoUpdateRegex();
221 bool CheckStringProp(CString
& s
, const std::string
& propname
, const CString
& propval
, LPCSTR prop
);
223 bool regExNeedUpdate
;
224 std::tr1::wregex regCheck
;
225 std::tr1::wregex regBugID
;
227 int nBugIdPos
; ///< result of sMessage.Find(L"%BUGID%");
230 friend class PropTest
;