Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
=begin Subversion tag support for Capistrano 2. * Place this file somewhere in your Rails app (for example in lib/tasks/capistrano_svn_tags.rb). * Load it in your Capfile, for example load 'lib/tasks/capistrano_svn_tags' If you load the default Capistrano recipe (load 'config/deploy') make sure this file is loaded before it! * Create a tag of a stable version of your code, for example svn cp http://dev.example.com/svn/pimpr/trunk \ http://dev.example.com/svn/pimpr/tags/v1.5 The library assumes standard subversion repository layout, i.e. tags reside in 'tags' directory. If you keep your releasable versions in another directory, for example stable_releases, set appropriately svn_tag_dir variable in your recipe: set :svn_tag_dir, 'stable_releases' * 'cap deploy' finds automatically the latest (in alphabetical order!) tag and deploys it. 'cap deploy TAG=v2.3' deploys a specific tag. * 'cap deploy:rollback' works too, reverting to the preceding (in alphabetical order!) already deployed tag. * For questions and comments write to sava@tutuf.com Copyright (c) 2008, Sava Chankov <sava@tutuf.com>, Tutuf Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Tutuf Ltd. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY Tutuf Ltd. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Tutuf Ltd. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =end namespace :deploy do # The standard subversion repository dir in which tags reside. set :svn_tag_dir, 'tags' desc "Pull source code with the provided (or latest if none given) tag to the remote servers." task :update_tag do set_release_tag logger.info "deploying tag #{release_name}" set :repository, "#{repository}/#{svn_tag_dir}/#{release_name}" end before "deploy:update_code", "deploy:update_tag" def set_release_tag set :release_name, ENV['TAG'] unless release_name logger.info "no tag specified, assuming latest" set(:release_name) {source.latest_tag} end end end require 'capistrano/recipes/deploy/scm/subversion' Capistrano::Deploy::SCM::Subversion.class_eval do #Find the last in alphabetical order tag def latest_tag logger.debug "querying latest tag ..." unless @latest_revision tags_dir = configuration.repository + '/' + configuration.svn_tag_dir + '/' @latest_revision = ls(tags_dir).split("\n").last.chomp('/') end alias_method :latest_revision, :latest_tag def ls(path) `#{scm} ls #{path}` end end
This paste will be private.
From the Design Piracy series on my blog: