Maybe run the QA script should be one of them?<br><br><div class="gmail_quote"><div dir="ltr">El vie., 20 de jul. de 2018 8:46 a. m., Martin Renvoize <<a href="mailto:martin.renvoize@ptfs-europe.com">martin.renvoize@ptfs-europe.com</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I use git-hooks pretty extensively though I'm still porting many of them from the project I've been working on for the last year for use with Koha.<div><br></div><div>There's so much you can do, for instance, I used to always run perltidy over any changed files in my commit to ensuring I stayed tidy (won't be porting that one).</div><div><br></div><div>The compile check is a great one too.. perhaps we should share more of these on the wiki?  There are a few in the release management and maintenance pages, but there's the scope that we could improve everyone's coding by suggesting some (I used to also run a perl lint script that would point out all my bad habbit and ensure I conformed to perl best practices.. it was a great way to learn and improve my perl).</div><div><br></div><div><div><div dir="ltr" class="m_-4255213511077062304gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><table cellspacing="0" cellpadding="0" width="410" style="font-family:'Times New Roman'"><tbody><tr><td colspan="2"><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>Martin Renvoize</strong></p></td></tr><tr><td colspan="2"><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)">Development Manager</p></td></tr><tr><td colspan="2"><p style="font-family:Arial;margin:0px"><br></p></td></tr><tr><td colspan="2"><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>T:</strong> +44 (0) 1483 378728</p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>F:</strong> +44 (0) 800 756 6384</p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><strong>E:</strong> <a href="mailto:martin.renvoize@ptfs-europe.com" style="color:rgb(45,92,136);text-decoration:none" target="_blank">martin.renvoize@ptfs-europe.com</a></p></td></tr><tr><td><p style="font-family:Arial;font-size:12px;line-height:20px;margin:0px;color:rgb(45,92,136)"><a href="https://www.ptfs-europe.com" style="color:rgb(45,92,136);text-decoration:none" target="_blank">www.ptfs-europe.com</a></p></td></tr><tr><td><p style="font-family:Arial;margin:0px"> </p></td></tr><tr><td colspan="2"><p style="line-height:20px;margin:0px"><a href="https://www.ptfs-europe.com" border="0" target="_blank"><img src="https://www.ptfs-europe.com/wp-content/uploads/2014/09/ptfs_logo1.png" width="" height="" border="0"></a></p></td></tr><tr><td><p style="font-family:Arial;margin:0px"><br></p></td></tr><tr><td><p style="font-family:Arial;margin:0px"><br></p></td></tr></tbody></table><table cellspacing="0" cellpadding="0" style="font-family:'Times New Roman';border-top-width:1px;border-top-style:solid;border-top-color:rgb(194,194,194);padding:20px 0px 0px;margin:0px"><tbody><tr><td><p style="font-family:Arial;font-size:12px;color:rgb(45,92,136);margin:0px">Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30</p><br><p style="font-family:Arial;font-size:12px;color:rgb(45,92,136);margin:0px">The information contained in this email message may be privileged, confidential and protected from disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this email message in error, please email the sender at <a href="mailto:info@ptfs-europe.com" target="_blank">info@ptfs-europe.com</a></p></td></tr></tbody></table><span style="font-size:12.8px"><br></span></div></div><div dir="ltr"></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 20 Jul 2018 at 09:53, David Cook <<a href="mailto:dcook@prosentient.com.au" target="_blank">dcook@prosentient.com.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-AU" link="#0563C1" vlink="#954F72"><div class="m_-4255213511077062304m_-9182163651966123865WordSection1"><p class="MsoNormal">Hi all,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">How many of you are using client-side git hooks? That is, git hooks that are in your working directory. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">A while ago, I added a “pre-commit” git hook in my Koha git working directory, which runs a little Python script every time I make a commit. It’s nothing fancy. Basically it gets a list of all the files I’m changing in Git and for a “.pl” or a “.pm” file, it runs “perl -c", which compiles the Perl code without running it (with a caveat about BEGIN{} blocks which do get run at compile time so could be a problem if you’re running untrusted code especially as a privileged user…). The Python script gets the exit code of that operation, and if there’s an error, it uses an exit code of 1 itself and prevents the commit from happening. I’ve attached some sample code to the bottom of this email under “__PYTHON_SCRIPT__”. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I find that it’s a nice way of catching errors. Maybe you write some code and you don’t think you need to test it, or you tested it but you made a last minute change and that last minute change has a typo… this catches that kind of things – at least if it’s an error which prevents successful compilation.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Anyway, I was just porting a patch between different versions of Koha, and everything looked good at a glance and the code merge was successful, but the commit failed because one variable name in one line of the many lines changed was slightly different. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The error messages told me exactly where to go and then it was obvious what the problem was and what to do. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Anyway, I just thought I’d share that. Maybe everyone is already using client-side git hooks, but I thought I’d share just in case someone else finds it useful. Especially as it saved my bacon just now. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span>David Cook<u></u><u></u></span></p><p class="MsoNormal"><span>Systems Librarian<u></u><u></u></span></p><p class="MsoNormal"><span>Prosentient Systems<u></u><u></u></span></p><p class="MsoNormal"><span>72/330 Wattle St<u></u><u></u></span></p><p class="MsoNormal"><span>Ultimo, NSW 2007<u></u><u></u></span></p><p class="MsoNormal"><span>Australia<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>Office: 02 9212 0899<u></u><u></u></span></p><p class="MsoNormal"><span>Direct: 02 8005 0595<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">__PYTHON_SCRIPT__<u></u><u></u></p><p class="MsoNormal">#!/usr/bin/env python<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">import subprocess, os<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">errors = 0<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">output = subprocess.check_output(["git","diff","--cached","--name-only","--diff-filter=ACMR"])<u></u><u></u></p><p class="MsoNormal">lines = output.split('\n')<u></u><u></u></p><p class="MsoNormal">for line in lines:<u></u><u></u></p><p class="MsoNormal">    if line:<u></u><u></u></p><p class="MsoNormal">        filename, file_extension = os.path.splitext(line)<u></u><u></u></p><p class="MsoNormal">        print(filename)<u></u><u></u></p><p class="MsoNormal">        print(file_extension)<u></u><u></u></p><p class="MsoNormal">        if file_extension == ".pl" or file_extension == ".pm":<u></u><u></u></p><p class="MsoNormal">            rv = subprocess.call(["perl","-c",line])<u></u><u></u></p><p class="MsoNormal">            if rv:<u></u><u></u></p><p class="MsoNormal">                errors += 1<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">if errors > 0:<u></u><u></u></p><p class="MsoNormal">    exit(1)<u></u><u></u></p></div></div>_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" target="_blank">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.org/</a></blockquote></div>
_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" target="_blank">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.org/</a></blockquote></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Tomás Cohen Arazi</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Theke Solutions (<a href="http://theke.io/">https://theke.io</a>)<br>✆ +54 9351 3513384<br>GPG: B2F3C15F</div></div></div>