[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

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

From: David Weintraub <qazwart_at_gmail.com>
Date: Tue, 16 Aug 2011 17:36:23 -0400

> 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_at_gmail.com
Received on 2011-08-16 23:36:52 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.