Add bugtraq to support commit dialog bug track.
[TortoiseGit.git] / src / TortoiseProc / ProjectProperties.h
blob31ebca80b3843d9b769a60a7209d28d74905411c
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 /**
88 * Searches for the BugID inside a log message. If one is found,
89 * that BugID is returned. If none is found, an empty string is returned.
90 * The \c msg is trimmed off the BugID.
92 CString GetBugIDFromLog(CString& msg);
94 /**
95 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
96 * functions checks if the bug ID doesn't contain any non-number chars in it.
98 BOOL CheckBugID(const CString& sID);
101 * Checks if the log message \c sMessage contains a bug ID. This is done by
102 * using the bugtraq:checkre property.
104 BOOL HasBugID(const CString& sMessage);
107 * Returns the URL pointing to the Issue in the issue tracker. The URL is
108 * created from the bugtraq:url property and the BugID found in the log message.
109 * \param msg the BugID extracted from the log message
111 CString GetBugIDUrl(const CString& sBugID);
114 * Inserts the tGit:autoprops into the Subversion config section.
115 * Call this before an import or an add operation.
117 //void InsertAutoProps(git_config_t *cfg);
120 * Adds all the project properties to the specified entry
122 bool AddAutoProps(const CTGitPath& path);
125 * Returns the log message summary if the tGit:logsummaryregex property is
126 * set and there are actually some matches.
127 * Otherwise, an empty string is returned.
129 CString GetLogSummary(const CString& sMessage);
132 * Returns the path from which the properties were read.
134 CTGitPath GetPropsPath() {return propsPath;}
135 public:
136 /** The label to show in the commit dialog where the issue number/bug id
137 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
138 CString sLabel;
140 /** The message string to add below the log message the user entered.
141 * It must contain the string "%BUGID%" which gets replaced by the client
142 * with the issue number / bug id the user entered. */
143 CString sMessage;
145 /** If this is set, then the bug-id / issue number must be a number, no text */
146 BOOL bNumber;
148 /** replaces bNumer: a regular expression string to check the validity of
149 * the entered bug ID. */
150 CString sCheckRe;
152 /** used to extract the bug ID from the string matched by sCheckRe */
153 CString sBugIDRe;
155 /** The url pointing to the issue tracker. If the url contains the string
156 * "%BUGID% the client has to replace it with the issue number / bug id
157 * the user entered. */
158 CString sUrl;
160 /** If set to TRUE, show a warning dialog if the user forgot to enter
161 * an issue number in the commit dialog. */
162 BOOL bWarnIfNoIssue;
164 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
165 log message instead of at the bottom. Default is TRUE */
166 BOOL bAppend;
168 /** The number of chars the width marker should be shown at. If the property
169 * is not set, then this value is 80 by default. */
170 int nLogWidthMarker;
172 /** The template to use for log messages. */
173 CString sLogTemplate;
175 /** Minimum size a log message must have in chars */
176 int nMinLogSize;
178 /** Minimum size a lock message must have in chars */
179 int nMinLockMsgSize;
181 /** TRUE if the file list to be inserted in the commit dialog should be in
182 * English and not in the localized language. Default is TRUE */
183 BOOL bFileListInEnglish;
185 /** The language identifier this project uses for log messages. */
186 LONG lProjectLanguage;
188 /** holds user defined properties for files. */
189 CString sFPPath;
191 /** holds user defined properties for directories. */
192 CString sDPPath;
194 /** The url pointing to the web viewer. The string %REVISION% is replaced
195 * with the revision number, "HEAD", or a date */
196 CString sWebViewerRev;
198 /** The url pointing to the web viewer. The string %REVISION% is replaced
199 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
200 * with the path relative to the repository root, e.g. "/trunk/src/file" */
201 CString sWebViewerPathRev;
204 * The regex string to extract a summary from a log message. The summary
205 * is the first matching regex group.
207 CString sLogSummaryRe;
208 private:
209 CString sAutoProps;
210 CTGitPath propsPath;
211 #ifdef DEBUG
212 friend class PropTest;
213 #endif