We use Tortoise SVN for source control, and have already set up a commit message template.
I would also like to display some text to the user when they commit, that doesn’t get included in their commit message, along the lines of “Don’t forget to do X!”.
Is this possible?
I have set up a similar environment using the Tortoise Docs and can say: Yes, it is! 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:
Start-Commit Hook
This hook gets passed three parameters:
PATH MESSAGEFILE CWD.MESSAGEFILEis the path to a temporary file that will be used for storing the commit message. You can fill this temporary file with your message Don’t forget to do X! Or, you prefix your message with something that you will treat as comment in the commit message and gets filtered out. Since Git uses#as comment in the commit message, I did the same: every line that starts with#gets filtered out of the commit message. And therefore I’d write the message# Don't forget to do X!. Sample implementation in Perl (untested):Pre-Commit Hook
This hook gets passed four parameters:
PATH DEPTH MESSAGEFILE CWD. The job of the pre-commit hook is to filter out the message that you filled intoMESSAGEFILEin 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 Don’t forget to do X! or – if you use the comment approach as I wrote above – delete every line that starts with a#sign (or that matches the pattern^\s*#) since it’s a comment in our world.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):
To activate the hooks, open the settings of TortoiseSVN, go to
hook scriptsand add the script once as start-commit hook and once as pre-commit hook. The command line to call would beperl /path/to/script. And also checkWait for the script to finishandHide script while running.Note
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 before the default parameters (as stated in the docs) get passed.