#!/usr/bin/perl use strict; use warnings; # This pre-commit hook for Subversion lets you add .doc files # only if the binary property was set on them. my ($path, $name) = @ARGV; my $SVNLOOK = '/usr/bin/svnlook'; my @changes = `$SVNLOOK changed $path --transaction $name`; my $err; foreach my $c (@changes) { #print STDERR "Line: $c"; if ($c =~ /^A\s+(.*\.doc)$/) { #if ($c =~ /^A\s+(.*)$/) { my $file = $1; #print STDERR "File: '$file'\n"; my $prop = `$SVNLOOK propget $path 'svn:mime-type' $file --transaction $name 2>/dev/null`; #print STDERR "Prop: '$prop'\n" if $prop; if ($prop ne 'application/octet-stream') { print STDERR "Must set 'svn:mime-type' to 'application/octet-stream'\n"; print STDERR "svn propset svn:mime-type application/octet-stream $file\n"; $err = 1; } } } if ($err) { exit 1; } exit 0;