Show Bug ID link at log dialog
[TortoiseGit.git] / src / TortoiseProc / ProjectProperties.h
blobad21796d5a0f98df070e3956efd952aed1348e96
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - 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.
19 #pragma once
20 #include <iostream>
21 #include <string>
22 #include "TGitPath.h"
23 using namespace std;
25 #define BUGTRAQPROPNAME_LABEL _T("bugtraq.label")
26 #define BUGTRAQPROPNAME_MESSAGE _T("bugtraq.message")
27 #define BUGTRAQPROPNAME_NUMBER _T("bugtraq.number")
28 #define BUGTRAQPROPNAME_LOGREGEX _T("bugtraq.logregex")
29 #define BUGTRAQPROPNAME_URL _T("bugtraq.url")
30 #define BUGTRAQPROPNAME_WARNIFNOISSUE _T("bugtraq.warnifnoissue")
31 #define BUGTRAQPROPNAME_APPEND _T("bugtraq.append")
33 #define PROJECTPROPNAME_LOGTEMPLATE _T("tsvn.logtemplate")
34 #define PROJECTPROPNAME_LOGWIDTHLINE _T("tsvn.logwidthmarker")
35 #define PROJECTPROPNAME_LOGMINSIZE _T("tsvn.logminsize")
36 #define PROJECTPROPNAME_LOCKMSGMINSIZE _T("tsvn.lockmsgminsize")
37 #define PROJECTPROPNAME_LOGFILELISTLANG _T("tsvn.logfilelistenglish")
38 #define PROJECTPROPNAME_LOGSUMMARY _T("tsvn.logsummary")
39 #define PROJECTPROPNAME_PROJECTLANGUAGE _T("tsvn.projectlanguage")
40 #define PROJECTPROPNAME_USERFILEPROPERTY _T("tsvn.userfileproperties")
41 #define PROJECTPROPNAME_USERDIRPROPERTY _T("tsvn.userdirproperties")
42 #define PROJECTPROPNAME_AUTOPROPS _T("tsvn.autoprops")
44 #define PROJECTPROPNAME_WEBVIEWER_REV _T("webviewer.revision")
45 #define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")
47 class CTSVNPathList;
48 struct svn_config_t;
50 /**
51 * \ingroup TortoiseProc
52 * Provides methods for retrieving information about bug/issue trackers
53 * associated with a Subversion repository/working copy and other project
54 * related properties.
56 class ProjectProperties
58 public:
59 ProjectProperties(void);
60 ~ProjectProperties(void);
62 /**
63 * Reads the properties from a path. If the path is a file
64 * then the properties are read from the parent folder of that file.
65 * \param path path to a file or a folder
67 BOOL ReadProps(CTGitPath path);
68 BOOL GetStringProps(CString &prop,TCHAR *key,bool bRemoveCR=true);
69 BOOL GetBOOLProps(BOOL &b, TCHAR*key);
70 /**
71 * Reads the properties from all paths found in a path list.
72 * This method calls ReadProps() for each path .
73 * \param list of paths
75 BOOL ReadPropsPathList(const CTGitPathList& pathList);
77 /**
78 * Searches for the BugID inside a log message. If one is found,
79 * the method returns TRUE. The rich edit control is used to set
80 * the CFE_LINK effect on the BugID's.
81 * \param msg the log message
82 * \param pWnd Pointer to a rich edit control
84 BOOL FindBugID(const CString& msg, CWnd * pWnd);
86 CString FindBugID(const CString& msg);
87 std::set<CString> FindBugIDs(const CString& msg);
88 /**
89 * Searches for the BugID inside a log message. If one is found,
90 * that BugID is returned. If none is found, an empty string is returned.
91 * The \c msg is trimmed off the BugID.
93 CString GetBugIDFromLog(CString& msg);
95 /**
96 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
97 * functions checks if the bug ID doesn't contain any non-number chars in it.
99 BOOL CheckBugID(const CString& sID);
102 * Checks if the log message \c sMessage contains a bug ID. This is done by
103 * using the bugtraq:checkre property.
105 BOOL HasBugID(const CString& sMessage);
108 * Returns the URL pointing to the Issue in the issue tracker. The URL is
109 * created from the bugtraq:url property and the BugID found in the log message.
110 * \param msg the BugID extracted from the log message
112 CString GetBugIDUrl(const CString& sBugID);
115 * Inserts the tGit:autoprops into the Subversion config section.
116 * Call this before an import or an add operation.
118 //void InsertAutoProps(git_config_t *cfg);
121 * Adds all the project properties to the specified entry
123 bool AddAutoProps(const CTGitPath& path);
126 * Returns the log message summary if the tGit:logsummaryregex property is
127 * set and there are actually some matches.
128 * Otherwise, an empty string is returned.
130 CString GetLogSummary(const CString& sMessage);
133 * Transform the log message using \ref GetLogSummary and post-process it
134 * to be suitable for 1-line controls.
136 CString MakeShortMessage(const CString& message);
139 * Returns the path from which the properties were read.
141 CTGitPath GetPropsPath() {return propsPath;}
142 public:
143 /** The label to show in the commit dialog where the issue number/bug id
144 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
145 CString sLabel;
147 /** The message string to add below the log message the user entered.
148 * It must contain the string "%BUGID%" which gets replaced by the client
149 * with the issue number / bug id the user entered. */
150 CString sMessage;
152 /** If this is set, then the bug-id / issue number must be a number, no text */
153 BOOL bNumber;
155 /** replaces bNumer: a regular expression string to check the validity of
156 * the entered bug ID. */
157 CString sCheckRe;
159 /** used to extract the bug ID from the string matched by sCheckRe */
160 CString sBugIDRe;
162 /** The url pointing to the issue tracker. If the url contains the string
163 * "%BUGID% the client has to replace it with the issue number / bug id
164 * the user entered. */
165 CString sUrl;
167 /** If set to TRUE, show a warning dialog if the user forgot to enter
168 * an issue number in the commit dialog. */
169 BOOL bWarnIfNoIssue;
171 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
172 log message instead of at the bottom. Default is TRUE */
173 BOOL bAppend;
175 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
176 interface. */
177 CString sProviderUuid;
179 /** the parameters passed to the COM bugtraq provider which implements the
180 IBugTraqProvider interface */
181 CString sProviderParams;
183 /** The number of chars the width marker should be shown at. If the property
184 * is not set, then this value is 80 by default. */
185 int nLogWidthMarker;
187 /** The template to use for log messages. */
188 CString sLogTemplate;
190 /** Minimum size a log message must have in chars */
191 int nMinLogSize;
193 /** Minimum size a lock message must have in chars */
194 int nMinLockMsgSize;
196 /** TRUE if the file list to be inserted in the commit dialog should be in
197 * English and not in the localized language. Default is TRUE */
198 BOOL bFileListInEnglish;
200 /** The language identifier this project uses for log messages. */
201 LONG lProjectLanguage;
203 /** holds user defined properties for files. */
204 CString sFPPath;
206 /** holds user defined properties for directories. */
207 CString sDPPath;
209 /** The url pointing to the web viewer. The string %REVISION% is replaced
210 * with the revision number, "HEAD", or a date */
211 CString sWebViewerRev;
213 /** The url pointing to the web viewer. The string %REVISION% is replaced
214 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
215 * with the path relative to the repository root, e.g. "/trunk/src/file" */
216 CString sWebViewerPathRev;
219 * The regex string to extract a summary from a log message. The summary
220 * is the first matching regex group.
222 CString sLogSummaryRe;
225 * A regex string to extract revisions from a log message.
227 CString sLogRevRegex;
228 private:
229 CString sAutoProps;
230 CTGitPath propsPath;
231 #ifdef DEBUG
232 friend class PropTest;
233 #endif