Add start and pre commit hooks
[TortoiseGit.git] / doc / source / en / TortoiseGit / tgit_dug / dug_settings_hooks.xml
blobd06fbc1c2149cc69ecf5b4240529c264bc9a6b48
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">\r
3 <sect2 id="tgit-dug-settings-hooks">\r
4         <title>Client Side Hook Scripts</title>\r
5         <?dbhh topicname="HIDD_SETTINGSHOOKS"?>\r
6         <?dbhh topicname="HIDD_SETTINGSHOOKCONFIG"?>\r
7         <indexterm>\r
8                 <primary>client hooks</primary>\r
9         </indexterm>\r
10         <indexterm>\r
11                 <primary>hook scripts</primary>\r
12         </indexterm>\r
13         <para>\r
14                 <figure id="tgit-dug-settings-dia-hooks">\r
15                         <title>The Settings Dialog, Hook Scripts Page</title>\r
16                         <graphic fileref="../images/SettingsHooks.png"/>\r
17                 </figure>\r
18                 This dialog allows you to set up hook scripts which will be\r
19                 executed automatically when certain TortoiseGit actions are performed on the client side.\r
20         </para>\r
21         <para>\r
22                 For various security and implementation reasons, hook scripts are defined\r
23                 locally on a machine, rather than as project properties. You define what\r
24                 happens, no matter what someone else commits to the repository. Of course\r
25                 you can always choose to call a script which is itself under version control.\r
26         </para>\r
27         <para>\r
28                 <figure id="tgit-dug-settings-dia-hook-edit">\r
29                         <title>The Settings Dialog, Configure Hook Scripts</title>\r
30                         <graphic fileref="../images/SettingsHookEdit.png"/>\r
31                 </figure>\r
32                 To add a new hook script, simply click <guibutton>Add</guibutton>\r
33                 and fill in the details.\r
34         </para>\r
35         <para>\r
36                 There are currently six types of hook script available\r
37                 <variablelist>\r
38                         <varlistentry>\r
39                                 <term>Start-commit</term>\r
40                                 <listitem>\r
41                                         <para>\r
42                                                 Called before the commit dialog is shown.\r
43                                                 You might want to use this if the hook modifies a versioned\r
44                                                 file and affects the list of files that need to be committed\r
45                                                 and/or commit message. However you should note that because\r
46                                                 the hook is called at an early stage, the full list of objects\r
47                                                 selected for commit is not available.\r
48                                         </para>\r
49                                 </listitem>\r
50                         </varlistentry>\r
51                         <varlistentry>\r
52                                 <term>Pre-commit</term>\r
53                                 <listitem>\r
54                                         <para>\r
55                                                 Called after the user clicks <guibutton>OK</guibutton>\r
56                                                 in the commit dialog, and before the actual commit begins.\r
57                                                 This hook has a list of exactly what will be committed.\r
58                                         </para>\r
59                                 </listitem>\r
60                         </varlistentry>\r
61                         <!--\r
62                         <varlistentry>\r
63                                 <term>Post-commit</term>\r
64                                 <listitem>\r
65                                         <para>\r
66                                                 Called after the commit finishes (whether successful or not).\r
67                                         </para>\r
68                                 </listitem>\r
69                         </varlistentry>\r
70                         -->\r
71                         <varlistentry>\r
72                                 <term>Pre-push</term>\r
73                                 <listitem>\r
74                                         <para>\r
75                                                 Called before actual Git push begins.\r
76                                         </para>\r
77                                 </listitem>\r
78                         </varlistentry>\r
79                         <varlistentry>\r
80                                 <term>Post-push</term>\r
81                                 <listitem>\r
82                                         <para>\r
83                                                 Called after pushing finishes (whether successful or not).\r
84                                         </para>\r
85                                 </listitem>\r
86                         </varlistentry>\r
87                 </variablelist>\r
88         </para>\r
89         <para>\r
90                 A hook is defined for a particular working tree path. You only need to\r
91                 specify the top level path; if you perform an operation in a sub-folder,\r
92                 TortoiseGit will automatically search upwards for a matching path.\r
93         </para>\r
94         <para>\r
95                 Next you must specify the command line to execute, starting with the path\r
96                 to the hook script or executable.\r
97                 This could be a batch file, an executable file or any other file which\r
98                 has a valid windows file association, eg. a perl script.\r
99         </para>\r
100         <para>\r
101                 The command line includes several parameters which get filled in\r
102                 by TortoiseGit. The parameters passed depend upon which hook is called.\r
103                 Each hook has its own parameters which are passed in the following order:\r
104                 <variablelist>\r
105                         <varlistentry>\r
106                                 <term>Start-commit</term>\r
107                                 <listitem condition="pot">\r
108                                         <para>\r
109                                                 <literal>PATH</literal>\r
110                                                 <literal>MESSAGEFILE</literal>\r
111                                                 <literal>CWD</literal>\r
112                                         </para>\r
113                                 </listitem>\r
114                         </varlistentry>\r
115                         <varlistentry>\r
116                                 <term>Pre-commit</term>\r
117                                 <listitem condition="pot">\r
118                                         <para>\r
119                                                 <literal>PATH</literal>\r
120                                                 <literal>MESSAGEFILE</literal>\r
121                                                 <literal>CWD</literal>\r
122                                         </para>\r
123                                 </listitem>\r
124                         </varlistentry>\r
125                         <!--\r
126                         <varlistentry>\r
127                                 <term>Post-commit</term>\r
128                                 <listitem condition="pot">\r
129                                         <para>\r
130                                                 <literal>PATH</literal>\r
131                                                 <literal>MESSAGEFILE</literal>\r
132                                                 <literal>REVISION</literal>\r
133                                                 <literal>ERROR</literal>\r
134                                                 <literal>CWD</literal>\r
135                                         </para>\r
136                                 </listitem>\r
137                         </varlistentry>\r
138                         -->\r
139                         <varlistentry>\r
140                                 <term>Pre-push</term>\r
141                                 <listitem condition="pot">\r
142                                         <para>\r
143                                                 <literal>PATH</literal>\r
144                                                 <literal>ERROR</literal>\r
145                                                 <literal>CWD</literal>\r
146                                         </para>\r
147                                 </listitem>\r
148                         </varlistentry>\r
149                         <varlistentry>\r
150                                 <term>Post-push</term>\r
151                                 <listitem condition="pot">\r
152                                         <para>\r
153                                                 <literal>PATH</literal>\r
154                                                 <literal>ERROR</literal>\r
155                                                 <literal>CWD</literal>\r
156                                         </para>\r
157                                 </listitem>\r
158                         </varlistentry>\r
159                 </variablelist>\r
160         </para>\r
161         <para>\r
162                 The meaning of each of these parameters is described here:\r
163                 <variablelist>\r
164                         <varlistentry>\r
165                                 <term condition="pot">PATH</term>\r
166                                 <listitem>\r
167                                         <para>\r
168                                                 A path to a temporary file which contains all the\r
169                                                 paths for which the operation was started.\r
170                                                 Each path is on a separate line in the temp file.\r
171                                         </para>\r
172                                 </listitem>\r
173                         </varlistentry>\r
174                         <varlistentry>\r
175                                 <term condition="pot">MESSAGEFILE</term>\r
176                                 <listitem>\r
177                                         <para>\r
178                                                 Path to a file containing the log message for\r
179                                                 the commit. The file contains the text in UTF-8\r
180                                                 encoding. After successful execution of the\r
181                                                 start-commit and pre-commit hooks, the log message is read back,\r
182                                                 giving the hook a chance to modify it.\r
183                                         </para>\r
184                                 </listitem>\r
185                         </varlistentry>\r
186                         <!--\r
187                         <varlistentry>\r
188                                 <term condition="pot">REVISION</term>\r
189                                 <listitem>\r
190                                         <para>\r
191                                                 The repository revision to which the update should\r
192                                                 be done or after a commit completes.\r
193                                         </para>\r
194                                 </listitem>\r
195                         </varlistentry>\r
196                         -->\r
197                         <varlistentry>\r
198                                 <term condition="pot">ERROR</term>\r
199                                 <listitem>\r
200                                         <para>\r
201                                                 Path to a file containing the error message.\r
202                                                 If there was no error, the file will be empty.\r
203                                         </para>\r
204                                 </listitem>\r
205                         </varlistentry>\r
206                         <varlistentry>\r
207                                 <term condition="pot">CWD</term>\r
208                                 <listitem>\r
209                                         <para>\r
210                                                 The current working directory with which the script is run.\r
211                                                 This is set to the working tree root.\r
212                                         </para>\r
213                                 </listitem>\r
214                         </varlistentry>\r
215                 </variablelist>\r
216         </para>\r
217         <para>\r
218                 Note that although we have given these parameters names for convenience,\r
219                 you do not have to refer to those names in the hook settings.\r
220                 All parameters listed for a particular hook are always passed,\r
221                 whether you want them or not ;-)\r
222         </para>\r
223         <para>\r
224                 If you want the Git operation to hold off until the hook has completed,\r
225                 check <guilabel>Wait for the script to finish</guilabel>.\r
226         </para>\r
227         <para>\r
228                 Normally you will want to hide ugly DOS boxes when the script runs,\r
229                 so <guilabel>Hide the script while running</guilabel> is checked by default.\r
230         </para>\r
231         <sect3 id="tgit-dug-settings-hooks-issuetracker">\r
232                 <title>Issue Tracker Integration</title>\r
233                 <?dbhh topicname="HIDD_SETTINGSBUGTRAQ"?>\r
234                 <?dbhh topicname="HIDD_SETTINGSBUGTRAQADV"?>\r
235                 <para>\r
236                         TortoiseGit can use a COM plugin to query issue trackers when in the\r
237                         commit dialog. The use of such plugins is described in\r
238                         <xref linkend="tgit-dug-bugtracker-ref" />.\r
239                         If your system administrator has provided you with a plugin, which\r
240                         you have already installed and registered, this is the place to\r
241                         specify how it integrates with your working tree.\r
242                 </para>\r
243                 <tip>\r
244                         There is also a hierarchical git configuration to associate issue tracker plugin with your project,\r
245                         rather than with to a specific directory path. Such settings are more portable.\r
246                         See <xref linkend="tgit-dug-bugtracker"/> to configure these settings.\r
247                 </tip>\r
248                 <para>\r
249                         <figure id="tgit-dug-settings-dia-issuetracker">\r
250                                 <title>The Settings Dialog, Issue Tracker Integration Page</title>\r
251                                 <graphic fileref="../images/SettingsIssueTrackerIntegration.png"/>\r
252                                 <graphic fileref="../images/SettingsIssueTracker.png"/>\r
253                         </figure>\r
254                         Click on <guibutton>Add...</guibutton> to use the plugin with\r
255                         a particular working tree. Here you can specify the working tree\r
256                         path, choose which plugin to use from a drop down list of all\r
257                         registered issue tracker plugins, and any parameters to pass.\r
258                         The parameters will be specific to the plugin, but might include\r
259                         your user name on the issue tracker so that the plugin can\r
260                         query for issues which are assigned to you.\r
261                 </para>\r
262         </sect3>\r
263         <sect3 id="tgit-dug-settings-hooks-issuetracker-config">\r
264         <title>Config</title>\r
265                 <para>\r
266                         <figure id="tgit-dug-settings-hooks-issuetrack-config">\r
267                                 <title>The Settings Dialog, Issue Tracker Config</title>\r
268                                 <graphic fileref="../images/SettingsIssueTrackerConfig.png"/>\r
269                         </figure>\r
270                         See  <xref linkend="tgit-dug-bugtracker"/> for a descriptions of the different options.\r
271                 </para>\r
272                 <important>\r
273                         <para>\r
274                                 If you have problems entering/storing data please see <xref linkend="tgit-dug-settings-hierachical"/>.\r
275                         </para>\r
276                 </important>\r
277         </sect3>\r
278 </sect2>\r