Blog's control panel: | Home | Tags | Index | Rss 2.0

Svn: forcing mime-types

Mon, 30 Apr 2007 | Permalink | Tags: ,

I had some developers coming over complaining that svn was interpreting javascript files as binary and asking if I could fix it. At first it sounded simple, I expected some server side config in the repository where I could set these kind of things, but that's not the way it works...
There isn't anything like that, mime-type is managed, like many other things, as a svn property. Don't get me wrong, properties are very powerful and a lifesaver, but in this case it meant relying on "users" compared to tweaking a single file on the server.

To set mime-type for a file you need to issue a "svn propset svn:mime-type 'text/javascript'", or whatever is appropriate. It's also possible to automate this process by setting enable-auto-props = yes in the svn client's config file (default $HOME/.subversion/config under unix), and then define in the [auto-props] block what you need to be applied. In my case:

[miscellany]
...
...
enable-auto-props = yes

### Section for configuring automatic properties.
[auto-props]
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match will be applied to the file.
### Note that auto-props functionality must be enabled, which
### is typically done by setting the 'enable-auto-props' option.
...
*.js = svn:mime-type=text/javascript




SpikeLab.org is a Filippo Spike Morelli copyright 2005-2008
This work is licensed under Creative Commons Att-SA License.