vladimirg
vladimirg

Reputation: 72

Combine some files after SVN commit

In short, I want to combine all JavaScript- files in my project into one file after each commit and include 'compiled' files in this commit\revision. What I should do?

I tried to use post-commit hook, post-revprop-change, but either I am stupid or it can't helps me.

Upvotes: 1

Views: 37

Answers (1)

neves
neves

Reputation: 39153

First, you shouldn't include generated or 'compiled' files in you version control repository. See this SO answer for the reasoning about it. The best option would be to have a build script that generates the combined files with a simple command and add it to your deploy process. The generated files should be added to the svn:ignore property.

For your specific problem, there are even web server modules, like Google mod_pagespeed, that automatically combine javascript files. This solution is a lot better than including generated code in your repository.

Now, if you really want to do it, you should do with a pre-commit hook. You should generate your files before sending them to version control. See that you will have a lot of trouble with it:

  1. First: the subversion hooks run in the machine where is your subversion server, so you need all the scripts that will generate the files located there.
  2. The consequence is that you won't have the generated files in your local workspace, you'll need to do an update after each commit. Terrible!
  3. You have to take care to add the file to subversion if it isn't under version control
  4. If for any reason there is a conflict commiting this file, your users will have a hell of a time trying to debug it.

If you follow this monstruous path, please don't tell anyone that I've told you how to do it :-)

Upvotes: 3

Related Questions