1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 #include "TGitPath.h"
\r
24 using namespace std;
\r
26 #define BUGTRAQPROPNAME_LABEL _T("bugtraq.label")
\r
27 #define BUGTRAQPROPNAME_MESSAGE _T("bugtraq.message")
\r
28 #define BUGTRAQPROPNAME_NUMBER _T("bugtraq.number")
\r
29 #define BUGTRAQPROPNAME_LOGREGEX _T("bugtraq.logregex")
\r
30 #define BUGTRAQPROPNAME_URL _T("bugtraq.url")
\r
31 #define BUGTRAQPROPNAME_WARNIFNOISSUE _T("bugtraq.warnifnoissue")
\r
32 #define BUGTRAQPROPNAME_APPEND _T("bugtraq.append")
\r
34 #define PROJECTPROPNAME_LOGTEMPLATE _T("tsvn.logtemplate")
\r
35 #define PROJECTPROPNAME_LOGWIDTHLINE _T("tsvn.logwidthmarker")
\r
36 #define PROJECTPROPNAME_LOGMINSIZE _T("tsvn.logminsize")
\r
37 #define PROJECTPROPNAME_LOCKMSGMINSIZE _T("tsvn.lockmsgminsize")
\r
38 #define PROJECTPROPNAME_LOGFILELISTLANG _T("tsvn.logfilelistenglish")
\r
39 #define PROJECTPROPNAME_LOGSUMMARY _T("tsvn.logsummary")
\r
40 #define PROJECTPROPNAME_PROJECTLANGUAGE _T("tsvn.projectlanguage")
\r
41 #define PROJECTPROPNAME_USERFILEPROPERTY _T("tsvn.userfileproperties")
\r
42 #define PROJECTPROPNAME_USERDIRPROPERTY _T("tsvn.userdirproperties")
\r
43 #define PROJECTPROPNAME_AUTOPROPS _T("tsvn.autoprops")
\r
45 #define PROJECTPROPNAME_WEBVIEWER_REV _T("webviewer.revision")
\r
46 #define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")
\r
48 class CTSVNPathList;
\r
49 struct svn_config_t;
\r
52 * \ingroup TortoiseProc
\r
53 * Provides methods for retrieving information about bug/issue trackers
\r
54 * associated with a Subversion repository/working copy and other project
\r
55 * related properties.
\r
57 class ProjectProperties
\r
60 ProjectProperties(void);
\r
61 ~ProjectProperties(void);
\r
64 * Reads the properties from a path. If the path is a file
\r
65 * then the properties are read from the parent folder of that file.
\r
66 * \param path path to a file or a folder
\r
68 BOOL ReadProps(CTGitPath path);
\r
69 static BOOL GetStringProps(CString &prop,TCHAR *key,bool bRemoveCR=true);
\r
70 static BOOL GetBOOLProps(BOOL &b, TCHAR*key);
\r
72 * Reads the properties from all paths found in a path list.
\r
73 * This method calls ReadProps() for each path .
\r
74 * \param list of paths
\r
76 BOOL ReadPropsPathList(const CTGitPathList& pathList);
\r
79 * Searches for the BugID inside a log message. If one is found,
\r
80 * the method returns TRUE. The rich edit control is used to set
\r
81 * the CFE_LINK effect on the BugID's.
\r
82 * \param msg the log message
\r
83 * \param pWnd Pointer to a rich edit control
\r
85 BOOL FindBugID(const CString& msg, CWnd * pWnd);
\r
87 CString FindBugID(const CString& msg);
\r
88 std::set<CString> FindBugIDs(const CString& msg);
\r
90 * Searches for the BugID inside a log message. If one is found,
\r
91 * that BugID is returned. If none is found, an empty string is returned.
\r
92 * The \c msg is trimmed off the BugID.
\r
94 CString GetBugIDFromLog(CString& msg);
\r
97 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
\r
98 * functions checks if the bug ID doesn't contain any non-number chars in it.
\r
100 BOOL CheckBugID(const CString& sID);
\r
103 * Checks if the log message \c sMessage contains a bug ID. This is done by
\r
104 * using the bugtraq:checkre property.
\r
106 BOOL HasBugID(const CString& sMessage);
\r
109 * Returns the URL pointing to the Issue in the issue tracker. The URL is
\r
110 * created from the bugtraq:url property and the BugID found in the log message.
\r
111 * \param msg the BugID extracted from the log message
\r
113 CString GetBugIDUrl(const CString& sBugID);
\r
116 * Inserts the tGit:autoprops into the Subversion config section.
\r
117 * Call this before an import or an add operation.
\r
119 //void InsertAutoProps(git_config_t *cfg);
\r
122 * Adds all the project properties to the specified entry
\r
124 bool AddAutoProps(const CTGitPath& path);
\r
127 * Returns the log message summary if the tGit:logsummaryregex property is
\r
128 * set and there are actually some matches.
\r
129 * Otherwise, an empty string is returned.
\r
131 CString GetLogSummary(const CString& sMessage);
\r
134 * Transform the log message using \ref GetLogSummary and post-process it
\r
135 * to be suitable for 1-line controls.
\r
137 CString MakeShortMessage(const CString& message);
\r
140 * Returns the path from which the properties were read.
\r
142 CTGitPath GetPropsPath() {return propsPath;}
\r
144 /** The label to show in the commit dialog where the issue number/bug id
\r
145 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
\r
148 /** The message string to add below the log message the user entered.
\r
149 * It must contain the string "%BUGID%" which gets replaced by the client
\r
150 * with the issue number / bug id the user entered. */
\r
153 /** If this is set, then the bug-id / issue number must be a number, no text */
\r
156 /** replaces bNumer: a regular expression string to check the validity of
\r
157 * the entered bug ID. */
\r
160 /** used to extract the bug ID from the string matched by sCheckRe */
\r
163 /** The url pointing to the issue tracker. If the url contains the string
\r
164 * "%BUGID% the client has to replace it with the issue number / bug id
\r
165 * the user entered. */
\r
168 /** If set to TRUE, show a warning dialog if the user forgot to enter
\r
169 * an issue number in the commit dialog. */
\r
170 BOOL bWarnIfNoIssue;
\r
172 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
\r
173 log message instead of at the bottom. Default is TRUE */
\r
176 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
\r
178 CString sProviderUuid;
\r
180 /** the parameters passed to the COM bugtraq provider which implements the
\r
181 IBugTraqProvider interface */
\r
182 CString sProviderParams;
\r
184 /** The number of chars the width marker should be shown at. If the property
\r
185 * is not set, then this value is 80 by default. */
\r
186 int nLogWidthMarker;
\r
188 /** The template to use for log messages. */
\r
189 CString sLogTemplate;
\r
191 /** Minimum size a log message must have in chars */
\r
194 /** Minimum size a lock message must have in chars */
\r
195 int nMinLockMsgSize;
\r
197 /** TRUE if the file list to be inserted in the commit dialog should be in
\r
198 * English and not in the localized language. Default is TRUE */
\r
199 BOOL bFileListInEnglish;
\r
201 /** The language identifier this project uses for log messages. */
\r
202 LONG lProjectLanguage;
\r
204 /** holds user defined properties for files. */
\r
207 /** holds user defined properties for directories. */
\r
210 /** The url pointing to the web viewer. The string %REVISION% is replaced
\r
211 * with the revision number, "HEAD", or a date */
\r
212 CString sWebViewerRev;
\r
214 /** The url pointing to the web viewer. The string %REVISION% is replaced
\r
215 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
\r
216 * with the path relative to the repository root, e.g. "/trunk/src/file" */
\r
217 CString sWebViewerPathRev;
\r
220 * The regex string to extract a summary from a log message. The summary
\r
221 * is the first matching regex group.
\r
223 CString sLogSummaryRe;
\r
226 * A regex string to extract revisions from a log message.
\r
228 CString sLogRevRegex;
\r
230 CString sAutoProps;
\r
231 CTGitPath propsPath;
\r
233 friend class PropTest;
\r