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
8 <primary>client hooks</primary>
\r
11 <primary>hook scripts</primary>
\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
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
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
28 One application for such hooks might be to call a program like
\r
29 <literal>GitWCRev.exe</literal> (<xref linkend="tgit-gitwcrev"/>)
\r
30 to update version numbers after a commit,
\r
31 and perhaps to trigger a rebuild.
\r
34 <figure id="tgit-dug-settings-dia-hook-edit">
\r
35 <title>The Settings Dialog, Configure Hook Scripts</title>
\r
36 <graphic fileref="../images/SettingsHookEdit.png"/>
\r
38 To add a new hook script, simply click <guibutton>Add</guibutton>
\r
39 and fill in the details.
\r
42 There are currently six types of hook script available
\r
45 <term>Start-commit</term>
\r
48 Called before the commit dialog is shown.
\r
49 You might want to use this if the hook modifies a versioned
\r
50 file and affects the list of files that need to be committed
\r
51 and/or commit message. However you should note that because
\r
52 the hook is called at an early stage, the full list of objects
\r
53 selected for commit is not available.
\r
58 <term>Pre-commit</term>
\r
61 Called after the user clicks <guibutton>OK</guibutton>
\r
62 in the commit dialog, and before the actual commit begins.
\r
63 This hook has a list of exactly what will be committed.
\r
68 <term>Post-commit</term>
\r
71 Called after the commit finished successfully.
\r
76 <term>Pre-push</term>
\r
79 Called before actual Git push begins.
\r
84 <term>Post-push</term>
\r
87 Called after pushing finishes (whether successful or not).
\r
92 <term>Pre-rebase</term>
\r
95 Called before rebasing starts (after clicking on Start or autostart).
\r
102 A hook is defined for a particular working tree path. You only need to
\r
103 specify the top level path; if you perform an operation in a sub-folder,
\r
104 TortoiseGit will automatically search upwards for a matching path.
\r
105 Use <literal>*</literal> for matching all working trees.
\r
108 If the checkbox <guibutton>Run for this repository</guibutton> is checked then
\r
109 the hook script is attached to the current repository and configured
\r
110 automatically for every clone and checkout (the hook information is stored in
\r
111 the file <filename>.tgitconfig</filename> in the repository root so that it will
\r
112 be automatically shared with all other developers using TortoiseGit >= 2.7.1;
\r
113 for security reasons TortoiseGit asks the user before running a hook which
\r
114 is configured and shared in the repository).
\r
115 In this case, you can specify paths for the command line with the
\r
116 replacement string <literal>%root%</literal> for the path to the
\r
117 working tree folder. The hook script has to be inside the repository and
\r
118 also be checked out of course (please also note the security implications below).
\r
119 If a user locally configures a hook for the exact repository root folder, the client side
\r
120 defined hook takes precedence.
\r
123 Next you must specify the command line to execute, starting with the path
\r
124 to the hook script or executable.
\r
125 This could be a batch file, an executable file or any other file which
\r
126 has a valid windows file association, e.g. a perl script.
\r
129 The command line includes several parameters which get filled in
\r
130 by TortoiseGit. The parameters passed depend upon which hook is called.
\r
131 Each hook has its own parameters which are passed in the following order:
\r
134 <term>Start-commit</term>
\r
135 <listitem condition="pot">
\r
137 <literal>PATH</literal>
\r
138 <literal>MESSAGEFILE</literal>
\r
139 <literal>CWD</literal>
\r
144 <term>Pre-commit</term>
\r
145 <listitem condition="pot">
\r
147 <literal>PATH</literal>
\r
148 <literal>MESSAGEFILE</literal>
\r
149 <literal>CWD</literal>
\r
154 <term>Post-commit</term>
\r
155 <listitem condition="pot">
\r
157 <literal>CWD</literal>
\r
158 <literal>(commit was amend (true or false))</literal>
\r
163 <term>Pre-push</term>
\r
164 <listitem condition="pot">
\r
166 <literal>ERROR</literal>
\r
167 <literal>CWD</literal>
\r
172 <term>Post-push</term>
\r
173 <listitem condition="pot">
\r
175 <literal>ERROR</literal>
\r
176 <literal>CWD</literal>
\r
181 <term>Pre-rebase</term>
\r
182 <listitem condition="pot">
\r
184 <literal>(upstream branch)</literal>
\r
185 <literal>(rebased branch)</literal>
\r
186 <literal>ERROR</literal>
\r
187 <literal>CWD</literal>
\r
194 The meaning of each of these parameters is described here:
\r
197 <term condition="pot">PATH</term>
\r
200 A path to a temporary file which contains all the
\r
201 paths for which the operation was started in UTF-8 encoding.
\r
202 Each path is on a separate line in the temp file.
\r
207 <term condition="pot">MESSAGEFILE</term>
\r
210 Path to a file containing the log message for
\r
211 the commit. The file contains the text in UTF-8
\r
212 encoding. After successful execution of the
\r
213 start-commit and pre-commit hooks, the log message is read back,
\r
214 giving the hook a chance to modify it.
\r
220 <term condition="pot">REVISION</term>
\r
223 The repository revision to which the update should
\r
224 be done or after a commit completes.
\r
230 <term condition="pot">ERROR</term>
\r
233 Path to a file containing the error message.
\r
234 If there was no error, the file will be empty.
\r
239 <term condition="pot">CWD</term>
\r
242 The current working directory with which the script is run.
\r
243 This is set to the working tree root.
\r
250 Note that although we have given these parameters names for convenience,
\r
251 you do not have to refer to those names in the hook settings.
\r
252 All parameters listed for a particular hook are always passed,
\r
253 whether you want them or not ;-)
\r
256 If you want the Git operation to hold off until the hook has completed,
\r
257 check <guilabel>Wait for the script to finish</guilabel>.
\r
260 Normally you will want to hide ugly DOS boxes when the script runs,
\r
261 so <guilabel>Hide the script while running</guilabel> is checked by default.
\r
265 If you are executing a versioned file/script from the repository, please note that the file possibly
\r
266 gets altered by third parties unnoticed (e.g. after pull or merge).
\r
269 <sect3 id="tgit-dug-settings-hooks-issuetracker">
\r
270 <title>Issue Tracker Integration</title>
\r
271 <?dbhh topicname="HIDD_SETTINGSBUGTRAQ"?>
\r
272 <?dbhh topicname="HIDD_SETTINGSBUGTRAQADV"?>
\r
274 TortoiseGit can use a COM plugin to query issue trackers when in the
\r
275 commit dialog. The use of such plugins is described in
\r
276 <xref linkend="tgit-dug-bugtracker-ref" />.
\r
277 If your system administrator has provided you with a plugin, which
\r
278 you have already installed and registered, this is the place to
\r
279 specify how it integrates with your working tree.
\r
282 There is also a hierarchical git configuration to associate issue tracker plugin with your project,
\r
283 rather than with to a specific directory path. Such settings are more portable.
\r
284 See <xref linkend="tgit-dug-bugtracker"/> to configure these settings.
\r
287 <figure id="tgit-dug-settings-dia-issuetracker">
\r
288 <title>The Settings Dialog, Issue Tracker Integration Page</title>
\r
289 <graphic fileref="../images/SettingsIssueTrackerIntegration.png"/>
\r
290 <graphic fileref="../images/SettingsIssueTracker.png"/>
\r
292 Click on <guibutton>Add...</guibutton> to use the plugin with
\r
293 a particular working tree. Here you can specify the working tree
\r
294 path, choose which plugin to use from a drop down list of all
\r
295 registered issue tracker plugins, and any parameters to pass.
\r
296 The parameters will be specific to the plugin, but might include
\r
297 your user name on the issue tracker so that the plugin can
\r
298 query for issues which are assigned to you.
\r
301 <sect3 id="tgit-dug-settings-hooks-issuetracker-config">
\r
302 <title>Config</title>
\r
304 <figure id="tgit-dug-settings-hooks-issuetrack-config">
\r
305 <title>The Settings Dialog, Issue Tracker Config</title>
\r
306 <graphic fileref="../images/SettingsIssueTrackerConfig.png"/>
\r
308 See <xref linkend="tgit-dug-bugtracker"/> for a descriptions of the different options.
\r
312 If you have problems entering/storing data please see <xref linkend="tgit-dug-settings-hierarchical"/>.
\r