Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have set up a similar environment using the <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-hooks" rel="nofollow">Tortoise Docs</a> and can say: <strong>Yes, it is!</strong> Operation involves a Start-Commit Hook that fills in the lines that the user shall read and a Pre-Commit Hook that removes thee lines again:</p> <p><b>Start-Commit Hook</b><br> This hook gets passed three parameters: <code>PATH MESSAGEFILE CWD</code>. <code>MESSAGEFILE</code> is the path to a temporary file that will be used for storing the commit message. You can fill this temporary file with your message <em>Don't forget to do X!</em> Or, you prefix your message with something that you will treat as comment in the commit message and gets filtered out. Since Git uses <code>#</code> as comment in the commit message, I did the same: every line that starts with <code>#</code> gets filtered out of the commit message. And therefore I'd write the message <code># Don't forget to do X!</code>. Sample implementation in Perl (untested):</p> <pre><code>use strict; # what we always have use warnings; # what we always have use Fcntl ':flock'; # lock files when writing use Carp; # use croak instead of die use English qw( -no_match_vars ); # words instad of cryptic variables sub startcommit_hook{ # open the logfile my $logfilename = $ARGV[1]; # write hint line about supported tags open my $handle, '&gt;:utf8', $logfilename or croak "Opening $logfilename for writing failed\n"; flock $handle, LOCK_EX; print {$handle} "# Don't forget to do X!\n"; flock $handle, LOCK_UN; return close $handle or croak "unable to close $OS_ERROR"; } startcommit_hook(); </code></pre> <p><b>Pre-Commit Hook</b><br> This hook gets passed four parameters: <code>PATH DEPTH MESSAGEFILE CWD</code>. The job of the pre-commit hook is to filter out the message that you filled into <code>MESSAGEFILE</code> in in the start-commit hook (otherwise it will go as part of the commit message to the server and this probably isn't what you want). Either just delete your message <em>Don't forget to do X!</em> or &ndash;&nbsp;if you use the comment approach as I wrote above&nbsp;&ndash; delete every line that starts with a <code>#</code> sign (or that matches the pattern <code>^\s*#</code>) since it's a comment in our world. </p> <p>We could extend our file for the start-commit hook to handle also the pre-commit stuff since the number of parameters is different. The decision on which hook to call is made up of the parameter count passed to the script (also untested):</p> <pre><code>use strict; # what we always have use warnings; # what we always have use feature 'switch'; # for given-when construct use Fcntl ':flock'; # lock files when writing use Carp; # use croak instead of die use English qw( -no_match_vars ); # words instad of cryptic variables sub startcommit_hook{ # open the logfile my $logfilename = $ARGV[1]; # write hint line about supported tags open my $handle, '&gt;:utf8', $logfilename or croak "Opening $logfilename for writing failed\n"; flock $handle, LOCK_EX; print {$handle} "# Don't forget to do X!\n"; flock $handle, LOCK_UN; return close $handle or croak "unable to close $OS_ERROR"; } sub precommit_hook{ my $logfilename = $ARGV[2]; # first, read the logfile open my $handle,'&lt;:utf8',$logfilename or croak "Error reading file contents of $logfilename: $OS_ERROR\n"; my @content = &lt;$handle&gt;; close $handle or croak "unable to close: $OS_ERROR"; chomp @content; # now, write it, ignoring the comment lines open my $handle, '&gt;:utf8', $logfilename or croak "Opening $logfilename for writing failed\n"; flock $handle, LOCK_EX; foreach my $line(@content){ if($line !~ /^\s*#/){ # line has no comment, print it. print {$handle} $line . "\n"; } } flock $handle, LOCK_UN; close $handle or croak "unable to close $OS_ERROR"; return; } given($#ARGV){ when (3){startcommit_hook();} when (4) {precommit_hook();} # no user supplied -&gt; auto lookup default {croak "Invalid number of parameters";} } </code></pre> <p>To activate the hooks, open the settings of TortoiseSVN, go to <code>hook scripts</code> and add the script once as start-commit hook and once as pre-commit hook. The command line to call would be <code>perl /path/to/script</code>. And also check <code>Wait for the script to finish</code> and <code>Hide script while running</code>.</p> <p><b>Note</b><br> If you need further information passed to the hooks, you could also pass custom parameters when you assign the hooks in the settings of TortoiseSVN. If you assign custom parameters, these get passed to the hook <strong>before</strong> the default parameters (as stated in the <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-hooks" rel="nofollow">docs</a>) get passed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload