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.
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")
46 * \ingroup TortoiseProc
47 * Provides methods for retrieving information about bug/issue trackers
48 * associated with a git repository/working copy and other project
51 class ProjectProperties
54 ProjectProperties(void);
55 ~ProjectProperties(void);
58 * Reads the properties from the current working tree
63 int GetStringProps(CString
&prop
, const CString
&key
);
64 int GetBOOLProps(BOOL
&b
, const CString
&key
);
68 * Searches for the BugID inside a log message. If one is found,
69 * the method returns TRUE. The rich edit control is used to set
70 * the CFE_LINK effect on the BugID's.
71 * \param msg the log message
72 * \param pWnd Pointer to a rich edit control
75 std::vector
<CHARRANGE
> FindBugIDPositions(const CString
& msg
);
77 BOOL
FindBugID(const CString
& msg
, CWnd
* pWnd
);
79 CString
FindBugID(const CString
& msg
);
80 std::set
<CString
> FindBugIDs(const CString
& msg
);
83 * Check whether calling \ref FindBugID or \ref FindBugIDPositions
84 * is worthwhile. If the result is @a false, those functions would
85 * return empty strings or sets, respectively.
87 bool MightContainABugID();
90 * Searches for the BugID inside a log message. If one is found,
91 * that BugID is returned. If none is found, an empty string is returned.
92 * The \c msg is trimmed off the BugID.
94 CString
GetBugIDFromLog(CString
& msg
);
97 * Checks if the bug ID is valid. If bugtraq:number is 'true', then the
98 * functions checks if the bug ID doesn't contain any non-number chars in it.
100 BOOL
CheckBugID(const CString
& sID
);
103 * Checks if the log message \c sMessage contains a bug ID. This is done by
104 * using the bugtraq:checkre property.
106 BOOL
HasBugID(const CString
& sMessage
);
109 * Returns the URL pointing to the Issue in the issue tracker. The URL is
110 * created from the bugtraq:url property and the BugID found in the log message.
111 * \param msg the BugID extracted from the log message
113 CString
GetBugIDUrl(const CString
& sBugID
);
115 /** replaces bNumer: a regular expression string to check the validity of
116 * the entered bug ID. */
117 const CString
& GetCheckRe() const {return sCheckRe
;}
118 void SetCheckRe(const CString
& s
) {sCheckRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
120 /** used to extract the bug ID from the string matched by sCheckRe */
121 const CString
& GetBugIDRe() const {return sBugIDRe
;}
122 void SetBugIDRe(const CString
& s
) {sBugIDRe
= s
;regExNeedUpdate
=true;AutoUpdateRegex();}
125 const CString
& GetProviderUUID() const { return (sProviderUuid64
.IsEmpty() ? sProviderUuid
: sProviderUuid64
); }
127 const CString
& GetProviderUUID() const { return (sProviderUuid
.IsEmpty() ? sProviderUuid64
: sProviderUuid
); }
131 /** The label to show in the commit dialog where the issue number/bug id
132 * is entered. Example: "Bug-ID: " or "Issue-No.:". Default is "Bug-ID :" */
135 /** The message string to add below the log message the user entered.
136 * It must contain the string "%BUGID%" which gets replaced by the client
137 * with the issue number / bug id the user entered. */
140 /** If this is set, then the bug-id / issue number must be a number, no text */
143 /** replaces bNumer: a regular expression string to check the validity of
144 * the entered bug ID. */
147 /** used to extract the bug ID from the string matched by sCheckRe */
150 /** The url pointing to the issue tracker. If the url contains the string
151 * "%BUGID% the client has to replace it with the issue number / bug id
152 * the user entered. */
155 /** If set to TRUE, show a warning dialog if the user forgot to enter
156 * an issue number in the commit dialog. */
159 /** If set to FALSE, then the bug tracking entry is inserted at the top of the
160 log message instead of at the bottom. Default is TRUE */
163 /** the parameters passed to the COM bugtraq provider which implements the
164 IBugTraqProvider interface */
165 CString sProviderParams
;
167 /** The number of chars the width marker should be shown at. If the property
168 * is not set, then this value is 80 by default. */
171 /** Minimum size a log message must have in chars */
174 /** TRUE if the file list to be inserted in the commit dialog should be in
175 * English and not in the localized language. Default is TRUE */
176 BOOL bFileListInEnglish
;
178 /** The language identifier this project uses for log messages. */
179 LONG lProjectLanguage
;
181 /** The url pointing to the web viewer. The string %REVISION% is replaced
182 * with the revision number, "HEAD", or a date */
183 CString sWebViewerRev
;
185 /** The url pointing to the web viewer. The string %REVISION% is replaced
186 * with the revision number, "HEAD", or a date. The string %PATH% is replaced
187 * with the path relative to the repository root, e.g. "/trunk/src/file" */
188 CString sWebViewerPathRev
;
190 BOOL bWarnNoSignedOffBy
;
194 * A regex string to extract revisions from a log message.
196 CString sLogRevRegex
;
198 /** the COM uuid of the bugtraq provider which implements the IBugTraqProvider
200 CString sProviderUuid
;
201 CString sProviderUuid64
;
204 git_config
*gitconfig
;
207 * Constructing regex objects is expensive. Therefore, cache them here.
209 void AutoUpdateRegex();
211 bool CheckStringProp(CString
& s
, const std::string
& propname
, const CString
& propval
, LPCSTR prop
);
213 bool regExNeedUpdate
;
214 std::tr1::wregex regCheck
;
215 std::tr1::wregex regBugID
;
217 int nBugIdPos
; ///< result of sMessage.Find(L"%BUGID%");
220 friend class PropTest
;