You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Michael Toal <mt...@gmail.com> on 2011/08/16 22:52:41 UTC

Need to chaeck mime-type on a specific extension

Hi, I need to reject commits that have a file extension .mdl and don't have
svn:mime-type set to application/octet-stream.

Does anyone have a pre-commit hook that will do this or similar?
Thanks.
Michael.

Re: Need to chaeck mime-type on a specific extension

Posted by David Weintraub <qa...@gmail.com>.
> Hi, I need to reject commits that have a file extension .mdl and don't have
>  svn:mime-type set to application/octet-stream.
>
> Does anyone have a pre-commit hook that will do this or similar?

I just happen to have such a hook.

The hook is in Perl, but doesn't require anything that doesn't come
installed with Perl 5.8 or later (unless you want to use LDAP groups).

All you need is a control.ini file with this entry to do what you want:

[property ALL MDL files need the property "svn:mime-type" on them]
file = **/*.mdl
property = svn:mime-type
type = string
value = application/octet-stream

Try this version first:
http://dl.dropbox.com/u/433257/newest_svn_hooks.zip. This is a compete
rewrite and is much easier to understand and maintain. However, it
might still have a few bugs in it since it hasn't been widely
distributed.

I have an older version here:
http://dl.dropbox.com/u/433257/new_svn_hooks.zip. It's been more
battle tested, but has fewer features and the error messages are not
as clear. I wanted to add some user requested features, but realized
the code was pretty awful and rewrote it from scratch.

In this version, you can't use the "file" parameter. You use the
"match" parameter and provide it with a Perl regular expression like
this:

[property ALL MDL files need the property "svn:mime-type" on them]
match = \.mdl$
property = svn:mime-type
type = string
value = application/octet-stream

Let  me know how it works for you.

-- 
David Weintraub
qazwart@gmail.com