Mark Plaksin wrote:
> I'm sure you know this but when you talk about version control be
> sure to mention a syntax-checking pre-commit hook.  That has saved
> us countless hours.  This page has hooks for SVN and Git:
> http://reductivelabs.com/trac/puppet/wiki/PuppetVersionControl

Indeed, this helps a lot for catching the really obvious typos, thanks
Mark for helping to work out a good git hook.  One potential fix for
that is to check for deletions, like so:

--- puppet-update-hook~ 2009-07-23 09:53:52.000000000 -0400
+++ puppet-update-hook  2009-07-23 09:58:11.000000000 -0400
@@ -15,6 +15,10 @@
 do
     # skip lines showing parent commit
     test -z "$new_sha1" && continue
+
+    # skip deletions
+    [ "$new_sha1" = "0000000000000000000000000000000000000000" ] && continue
+
     # Only test .pp files
     if [[ $name =~ [.]pp$ ]]
     then

One other potential problem is if puppet is used to manage selinux
modules.  Compiled modules also have a .pp extension.  When adding or
updating these files they will pass the "if [[ $name =~ [.]pp$ ]]"
check.  This can be avoided by not version controlling the compiled
modules, but perhaps it might also be reasonable to add a quick bit to
the if test, something like this (untested):

    if [[ $name =~ [.]pp$ ]] && [ "$(file -b "$name" 2>/dev/null)" != 'data' ]

The selinux .pp files will return data, while I can't imaging any
puppet manifests being labeled as data. :)

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A lot of people I know believe in positive thinking, and so do I.  I
believe everything positively stinks.
    -- Lew Col

Attachment: pgpJekzt1x9JV.pgp
Description: PGP signature

Reply via email to