| SVN-Hooks documentation | Contained in the SVN-Hooks distribution. |
SVN::Hooks::CheckMimeTypes - Require the svn:mime-type property.
This SVN::Hooks plugin checks if the files added to the repository have the svn:mime-type property set. Moreover, for text files, it checks if the properties svn:eol-style and svn:keywords are also set.
The plugin was based on the check-mime-type.pl script.
It's active in the pre-commit hook.
It's configured by the following directive.
This directive enables the checking, causing the commit to abort if it doesn't comply.
The MESSAGE argument is an optional help message shown to the user in case the commit fails. Note that by default the plugin already inserts a rather verbose help message in case of errors.
CHECK_MIMETYPES("Use TortoiseSVN -> Properties menu option to set properties.");
Gustavo Chaves, <gnustavo@cpan.org>
Please report any bugs or feature requests to
bug-svn-hooks-checkmimetypes at rt.cpan.org, or through the web
interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SVN-Hooks. I will
be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc SVN::Hooks
You can also look for information at:
To the author of the check-mime-type.pl script at
http://svn.digium.com/view/repotools/check-mime-type.pl.
Copyright 2008-2009 CPqD, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| SVN-Hooks documentation | Contained in the SVN-Hooks distribution. |
package SVN::Hooks::CheckMimeTypes; use strict; use warnings; use Carp; use SVN::Hooks; use Exporter qw/import/; my $HOOK = 'CHECK_MIMETYPES'; our @EXPORT = ($HOOK); our $VERSION = $SVN::Hooks::VERSION;
my $Help = <<"EOS"; You may want to consider uncommenting the auto-props section in your ~/.subversion/config file. Read the Subversion book (http://svnbook.red-bean.com/), Chapter 7, Properties section, Automatic Property Setting subsection for more help. EOS sub CHECK_MIMETYPES { my ($help) = @_; $Help = $help if defined $help; PRE_COMMIT(\&pre_commit); return 1; } sub pre_commit { my ($svnlook) = @_; my @errors; foreach my $added ($svnlook->added()) { next if $added =~ m:/$:; # disregard directories my $props = $svnlook->proplist($added); unless (my $mimetype = $props->{'svn:mime-type'}) { push @errors, "property svn:mime-type is not set for: $added"; } elsif ($mimetype =~ m:^text/:) { for my $prop ('svn:eol-style', 'svn:keywords') { push @errors, "property $prop is not set for text file: $added" unless exists $props->{$prop}; } } } if (@errors) { croak "$HOOK:\n", join("\n", @errors), <<'EOS', $Help; Every added file must have the svn:mime-type property set. In addition, text files must have the svn:eol-style and svn:keywords properties set. For binary files try running svn propset svn:mime-type application/octet-stream path/of/file For text files try svn propset svn:mime-type text/plain path/of/file svn propset svn:eol-style native path/of/file svn propset svn:keywords 'Author Date Id Revision' path/of/file EOS } }
1; # End of SVN::Hooks::CheckMimeTypes