tags:

views:

26

answers:

1

I have a fairly complex WordPress + bbPress installation and I would like to handle version control for all the custom code in subversion. What follows is the approach I have settled on and I would appreciate input/critique. Is there a better way to do this?

Although my situation involves WordPress I am describing things in general terms and the problem applies to any number of other frameworks where you end up with large amounts of custom code spread around a larger system.

The hierarchy of the deployed site (below html root) looks as follows (somewhat simplified for illustration):

CUSTOM-directory
wp-admin
wp-content
  - <other directories>
  - themes
    - <CUSTOM theme directories>
    - <other theme directories>
  - plugins
    - <CUSTOM plugin files & directories>
    - <other plugin files & directories>
wp-includes
<other files>

I want to put all the directories that contain "CUSTOM" under version control. So I set up a hierarchy as follows and imported it into a new repo.

website
  - trunk
    - CUSTOM-directory
    - themes
    - plugins
  - branches
  - tags

Since "themes" and "plugins" in the deployed hierarchy contain files and folders in addition to my custom code, I added this other stuff to the ignore property of these two directories.

I am making changes in three places: a dev machine (where most of the action takes place), a staging/testing server that is almost identical to my production environment, and the production server (only minor changes). The initial setup in these three places is a little time consuming because I have to check out each directory below trunk into its correct place in the hierarchy. But that is a one-time hassle.

I wrote a few simple shell scripts to automate svn tasks once this is all set up. For example: svn-commit.sh (which would run from the root of the Wordpress installation)

#!/bin/sh
svn commit CUSTOM-directory "$@"
svn commit wp-content/plugins "$@"
svn commit wp-content/themes "$@"

I have also checked out a separate working copy on my dev machine that is purely my custom code so that I can do drag and drop repo maintenance using Versions.

So, what do you think? Is there an easier way? I also considered:

  1. Putting the whole mess under version control. I thought would create too much repo admin overhead as I dealt with other people refactoring their code.

  2. Putting the whole hierarchy under version control and setting ignore for everything but my code. Again, this would involve too much ongoing admin overhead maintaining the ignore properties.

Finally, are there any security issues around having .svn folders hanging around in my production site?

A: 

I like your approach. You only get under version control things which are going to change like plugins and themes and your custom directory. I think putting everything under version control would be unnecessary, since you would have to deal with WordPress changes too.

I don't know how your development environment is set up, but you could set a project with WordPress/bbPress and checkout your code into the project's folders, ignoring the rest of the folders. But the way you did it, I think it's just fine, not much overhead.

BTW, using svn export, you get all the files from the repo, without the .svn directories. You should use this commando for your production site. Or do a checkout, and prevent access to .svn directories in your web server.

Fernando