Strange Symphonies The best way to predict the future is to invent it

Related tags

15May/100

git-deploy Released

I am a big fan of Capistrano and in general, software deployment tools. Capistrano works by connecting to your server, and updating the software there.

Most of my clients get their hosting from a shared server hosting package, where the server is shared amongst multiple people. This is great, as it lowers the cost of hosting tremendously, but also the number of features the server comes with is reduced. Most shared server hosting providers allow FTP.

Sadly Capistrano requires one to have SSH access to the server. Thus Capistrano, isn't a feasible tool to use. Unable to find a substitute, I developed my own called git-deploy.

git-deploy will interact with git to only update relevant files on the server via FTP or SSH.

For example, if you only updated on file in your source code, you only need to upload one file, and not the whole directory. This makes uploading, more time and bandwidth efficient. Especially for time, as the script can be run from the command line, so you don't need to launch your upload program, select which files to upload, drag and drog, and wait. A lot of time can be saved.

This is done by storing a file called REVISION on the server, which we can compare with on the local machine.

I am personally using it now on this website, and other production sites.

I am planning to create a Ruby Gem out of the plugin, but unfortunately the name git-deploy was taken. I am still looking for a new name, so if you have a suggestion, just drop me a comment.

git-deploy is licensed under an MIT License, so feel free to use, change, and build on top of my code.

To find out more about git-deploy, and how to set it up visit its GitHub page.

Happy Deploying!

12Sep/090

Ruby on Rails git pre-commit hook

git provides a few hooks so you can control the workflow of your source code commits. These hooks are placed inside your .git/hooks directory, and a inside there are a few samples to look at.

For my Ruby on Rails applications, I use the git pre-commit hook, to ensure that my Ruby code syntax is correct, and that it passes all my RSpec tests.

In your application directory, create a file in the git directory: .git/hooks/pre-commit

#!/usr/bin/env ruby
# vim: set syntax=ruby

flag = false

Dir["{app,config,lib,runners}/**/*/*.rb"].each do |file|
  result = `ruby -c #{file}`

  if $? != 0
    puts result
    flag = true
  end
end

Dir["public/javascripts/**/*.js"].each do |file|
  result = `grep -n console #{file}`

  if $? == 0
    puts file
    puts result
    flag = true
  end
end

exit 1 if flag

exec "rake spec"

Don't forget to make it executable:

chmod u+x .git/hooks/pre-commit

Now you are ready to go.