Move some logic for getting config values to CAutoConfig
[TortoiseGit.git] / src / TortoiseProc / ProjectProperties.h
blob6fec56d142a1e834281c0c9afed97cd9d6bd5ed0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009,2011-2014 - 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.
20 #pragma once
21 #include "TGitPath.h"
22 #include <regex>
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_LOGWIDTHLINE _T("tgit.logwidthmarker")
36 #define PROJECTPROPNAME_LOGMINSIZE _T("tgit.logminsize")
37 #define PROJECTPROPNAME_LOGFILELISTLANG _T("tsvn.logfilelistenglish")
38 #define PROJECTPROPNAME_PROJECTLANGUAGE _T("tgit.projectlanguage")
39 #define PROJECTPROPNAME_WARNNOSIGNEDOFFBY _T("tgit.warnnosignedoffby")
40 #define PROJECTPROPNAME_ICON _T("tgit.icon")
42 #define PROJECTPROPNAME_WEBVIEWER_REV _T("webviewer.revision")
43 #define PROJECTPROPNAME_WEBVIEWER_PATHREV _T("webviewer.pathrevision")
45 /**
46 * \ingroup TortoiseProc
47 * Provides methods for retrieving information about bug/issue trackers
48 * associated with a git repository/working copy and other project
49 * related properties.
51 class ProjectProperties
53 public:
54 ProjectProperties(void);
56 /**
57 * Reads the properties from the current working tree
59 BOOL ReadProps();
61 public:
62 /**
63 * Searches for the BugID inside a log message. If one is found,
64 * the method returns TRUE. The rich edit control is used to set
65 * the CFE_LINK effect on the BugID's.
66 * \param msg the log message
67 * \param pWnd Pointer to a rich edit control
69 #ifdef _RICHEDIT_
70 std::vector<CHARRANGE> FindBugIDPositions(const CString& msg);
71 #endif
72 BOOL FindBugID(const CString& msg, CWnd * pWnd);
74 CString FindBugID(const CString& msg);
75 std::set<CString> FindBugIDs(const CString& msg);
77 /**
78 * Check whether calling \ref FindBugID or \ref FindBugIDPositions
79 * is worthwhile. If the result is @a false, those functions would
80 * return empty strings or sets, respectively.
82 bool MightContainABugID();
84 /**
85 * Searches for the BugID inside a log message. If one is found,
86 * that BugID is returned. If none is found, an empty string is returned.
87 * The \c msg is trimmed off the BugID.
89 CString GetBugIDFromLog(CString& msg);
91 /**
92 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
93 * functions checks if the bug ID doesn't contain any non-number chars in it.
95 BOOL CheckBugID(const CString& sID);
97 /**
98 * Checks if the log message \c sMessage contains a bug ID. This is done by
99 * using the bugtraq:checkre property.
101 BOOL HasBugID(const CString& sMessage);
104 * Returns the URL pointing to the Issue in the issue tracker. The URL is
105 * created from the bugtraq:url property and the BugID found in the log message.
106 * \param msg the BugID extracted from the log message
108 CString GetBugIDUrl(const CString& sBugID);
110 /** replaces bNumer: a regular expression string to check the validity of
111 * the entered bug ID. */
112 const CString& GetCheckRe() const {return sCheckRe;}
113 void SetCheckRe(const CString& s) {sCheckRe = s;regExNeedUpdate=true;AutoUpdateRegex();}
115 /** used to extract the bug ID from the string matched by sCheckRe */
116 const CString& GetBugIDRe() const {return sBugIDRe;}
117 void SetBugIDRe(const CString& s) {sBugIDRe = s;regExNeedUpdate=true;AutoUpdateRegex();}
119 #ifdef _WIN64
120 const CString& GetProviderUUID() const { return (sProviderUuid64.IsEmpty() ? sProviderUuid : sProviderUuid64); }
121 #else
122 const CString& GetProviderUUID() const { return (sProviderUuid.IsEmpty() ? sProviderUuid64 : sProviderUuid); }
123 #endif
125 public:
126 /** The label to show in the commit dialog where the issue number/bug id
127 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
128 CString sLabel;
130 /** The message string to add below the log message the user entered.
131 * It must contain the string "%BUGID%" which gets replaced by the client
132 * with the issue number / bug id the user entered. */
133 CString sMessage;
135 /** If this is set, then the bug-id / issue number must be a number, no text */
136 BOOL bNumber;
138 /** replaces bNumer: a regular expression string to check the validity of
139 * the entered bug ID. */
140 CString sCheckRe;
142 /** used to extract the bug ID from the string matched by sCheckRe */
143 CString sBugIDRe;
145 /** The url pointing to the issue tracker. If the url contains the string
146 * "%BUGID% the client has to replace it with the issue number / bug id
147 * the user entered. */
148 CString sUrl;
150 /** If set to TRUE, show a warning dialog if the user forgot to enter
151 * an issue number in the commit dialog. */
152 BOOL bWarnIfNoIssue;
154 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
155 log message instead of at the bottom. Default is TRUE */
156 BOOL bAppend;
158 /** the parameters passed to the COM bugtraq provider which implements the
159 IBugTraqProvider interface */
160 CString sProviderParams;
162 /** The number of chars the width marker should be shown at. If the property
163 * is not set, then this value is 80 by default. */
164 int nLogWidthMarker;
166 /** Minimum size a log message must have in chars */
167 int nMinLogSize;
169 /** TRUE if the file list to be inserted in the commit dialog should be in
170 * English and not in the localized language. Default is TRUE */
171 BOOL bFileListInEnglish;
173 /** The language identifier this project uses for log messages. */
174 LONG lProjectLanguage;
176 /** The url pointing to the web viewer. The string %REVISION% is replaced
177 * with the revision number, "HEAD", or a date */
178 CString sWebViewerRev;
180 /** The url pointing to the web viewer. The string %REVISION% is replaced
181 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
182 * with the path relative to the repository root, e.g. "/trunk/src/file" */
183 CString sWebViewerPathRev;
185 BOOL bWarnNoSignedOffBy;
186 CString sIcon;
189 * A regex string to extract revisions from a log message.
191 CString sLogRevRegex;
193 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
194 interface. */
195 CString sProviderUuid;
196 CString sProviderUuid64;
198 private:
200 * Constructing regex objects is expensive. Therefore, cache them here.
202 void AutoUpdateRegex();
204 bool CheckStringProp(CString& s, const std::string& propname, const CString& propval, LPCSTR prop);
206 bool regExNeedUpdate;
207 std::tr1::wregex regCheck;
208 std::tr1::wregex regBugID;
210 int nBugIdPos; ///< result of sMessage.Find(L"%BUGID%");
212 #ifdef DEBUG
213 friend class PropTest;
214 #endif