1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2011-2014, 2018 - 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 L"bugtraq.label"
25 #define BUGTRAQPROPNAME_MESSAGE L"bugtraq.message"
26 #define BUGTRAQPROPNAME_NUMBER L"bugtraq.number"
27 #define BUGTRAQPROPNAME_LOGREGEX L"bugtraq.logregex"
28 #define BUGTRAQPROPNAME_URL L"bugtraq.url"
29 #define BUGTRAQPROPNAME_WARNIFNOISSUE L"bugtraq.warnifnoissue"
30 #define BUGTRAQPROPNAME_APPEND L"bugtraq.append"
31 #define BUGTRAQPROPNAME_PROVIDERUUID L"bugtraq.provideruuid"
32 #define BUGTRAQPROPNAME_PROVIDERUUID64 L"bugtraq.provideruuid64"
33 #define BUGTRAQPROPNAME_PROVIDERPARAMS L"bugtraq.providerparams"
35 #define PROJECTPROPNAME_LOGWIDTHLINE L"tgit.logwidthmarker"
36 #define PROJECTPROPNAME_LOGMINSIZE L"tgit.logminsize"
37 #define PROJECTPROPNAME_LOGFILELISTLANG L"tsvn.logfilelistenglish"
38 #define PROJECTPROPNAME_PROJECTLANGUAGE L"tgit.projectlanguage"
39 #define PROJECTPROPNAME_WARNNOSIGNEDOFFBY L"tgit.warnnosignedoffby"
40 #define PROJECTPROPNAME_ICON L"tgit.icon"
42 #define PROJECTPROPNAME_WEBVIEWER_REV L"webviewer.revision"
43 #define PROJECTPROPNAME_WEBVIEWER_PATHREV L"webviewer.pathrevision"
45 #define PROJECTPROPNAME_STARTCOMMITHOOK L"hook.startcommit."
46 #define PROJECTPROPNAME_PRECOMMITHOOK L"hook.precommit."
47 #define PROJECTPROPNAME_POSTCOMMITHOOK L"hook.postcommit."
48 #define PROJECTPROPNAME_PREPUSHHOOK L"hook.prepush."
49 #define PROJECTPROPNAME_POSTPUSHHOOK L"hook.postpush."
50 #define PROJECTPROPNAME_PREREBASEHOOK L"hook.prerebase."
53 * \ingroup TortoiseProc
54 * Provides methods for retrieving information about bug/issue trackers
55 * associated with a git repository/working copy and other project
58 class ProjectProperties
61 ProjectProperties(void);
64 * Reads the properties from the current working tree
70 * Searches for the BugID inside a log message. If one is found,
71 * the method returns TRUE. The rich edit control is used to set
72 * the CFE_LINK effect on the BugID's.
73 * \param msg the log message
74 * \param pWnd Pointer to a rich edit control
77 std::vector
<CHARRANGE
> FindBugIDPositions(const CString
& msg
);
79 BOOL
FindBugID(const CString
& msg
, CWnd
* pWnd
);
81 CString
FindBugID(const CString
& msg
);
82 std::set
<CString
> FindBugIDs(const CString
& msg
);
85 * Check whether calling \ref FindBugID or \ref FindBugIDPositions
86 * is worthwhile. If the result is @a false, those functions would
87 * return empty strings or sets, respectively.
89 bool MightContainABugID();
92 * Searches for the BugID inside a log message. If one is found,
93 * that BugID is returned. If none is found, an empty string is returned.
94 * The \c msg is trimmed off the BugID.
96 CString
GetBugIDFromLog(CString
& msg
);
99 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
100 * functions checks if the bug ID doesn't contain any non-number chars in it.
102 BOOL
CheckBugID(const CString
& sID
);
105 * Checks if the log message \c sMessage contains a bug ID. This is done by
106 * using the bugtraq:checkre property.
108 BOOL
HasBugID(const CString
& sMessage
);
111 * Returns the URL pointing to the Issue in the issue tracker. The URL is
112 * created from the bugtraq:url property and the BugID found in the log message.
113 * \param msg the BugID extracted from the log message
115 CString
GetBugIDUrl(const CString
& sBugID
);
117 /** replaces bNumer: a regular expression string to check the validity of
118 * the entered bug ID. */
119 const CString
& GetCheckRe() const {return sCheckRe
;}
120 void SetCheckRe(const CString
& s
) {sCheckRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
122 /** used to extract the bug ID from the string matched by sCheckRe */
123 const CString
& GetBugIDRe() const {return sBugIDRe
;}
124 void SetBugIDRe(const CString
& s
) {sBugIDRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
127 const CString
& GetProviderUUID() const { return (sProviderUuid64
.IsEmpty() ? sProviderUuid
: sProviderUuid64
); }
129 const CString
& GetProviderUUID() const { return (sProviderUuid
.IsEmpty() ? sProviderUuid64
: sProviderUuid
); }
133 /** The label to show in the commit dialog where the issue number/bug id
134 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
137 /** The message string to add below the log message the user entered.
138 * It must contain the string "%BUGID%" which gets replaced by the client
139 * with the issue number / bug id the user entered. */
142 /** If this is set, then the bug-id / issue number must be a number, no text */
145 /** replaces bNumer: a regular expression string to check the validity of
146 * the entered bug ID. */
149 /** used to extract the bug ID from the string matched by sCheckRe */
152 /** The url pointing to the issue tracker. If the url contains the string
153 * "%BUGID% the client has to replace it with the issue number / bug id
154 * the user entered. */
157 /** If set to TRUE, show a warning dialog if the user forgot to enter
158 * an issue number in the commit dialog. */
161 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
162 log message instead of at the bottom. Default is TRUE */
165 /** the parameters passed to the COM bugtraq provider which implements the
166 IBugTraqProvider interface */
167 CString sProviderParams
;
169 /** The number of chars the width marker should be shown at. If the property
170 * is not set, then this value is 80 by default. */
173 /** Minimum size a log message must have in chars */
176 /** TRUE if the file list to be inserted in the commit dialog should be in
177 * English and not in the localized language. Default is TRUE */
178 BOOL bFileListInEnglish
;
180 /** The language identifier this project uses for log messages. */
181 LONG lProjectLanguage
;
183 /** The url pointing to the web viewer. The string %REVISION% is replaced
184 * with the revision number, "HEAD", or a date */
185 CString sWebViewerRev
;
187 /** The url pointing to the web viewer. The string %REVISION% is replaced
188 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
189 * with the path relative to the repository root, e.g. "/trunk/src/file" */
190 CString sWebViewerPathRev
;
192 BOOL bWarnNoSignedOffBy
;
196 * A regex string to extract revisions from a log message.
198 CString sLogRevRegex
;
200 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
202 CString sProviderUuid
;
203 CString sProviderUuid64
;
205 /// multi line string containing the data for a start-commit-hook
206 CString sStartCommitHook
;
207 /// multi line string containing the data for a pre-commit-hook
208 CString sPreCommitHook
;
209 /// multi line string containing the data for a post-commit-hook
210 CString sPostCommitHook
;
211 /// multi line string containing the data for a pre-push-hook
212 CString sPrePushHook
;
213 /// multi line string containing the data for a post-push-hook
214 CString sPostPushHook
;
215 /// multi line string containing the data for a pre-rebase-hook
216 CString sPreRebaseHook
;
220 * Constructing regex objects is expensive. Therefore, cache them here.
222 void AutoUpdateRegex();
224 void FetchHookString(CAutoConfig
& gitconfig
, const CString
& sBase
, CString
& sHook
);
226 bool regExNeedUpdate
;
227 std::wregex regCheck
;
228 std::wregex regBugID
;
230 int nBugIdPos
; ///< result of sMessage.Find(L"%BUGID%");
232 #ifdef GTEST_INCLUDE_GTEST_GTEST_H_
233 FRIEND_TEST(ProjectPropertiesTest
, ParseBugIDs
);