diff --git a/bin/capify b/bin/capify index a8fb8275..c598242d 100755 --- a/bin/capify +++ b/bin/capify @@ -49,7 +49,7 @@ files = { "config/deploy.rb" => 'set :application, "set your application name here" set :repository, "set your repository location here" -set :scm, :subversion +# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` role :web, "your web-server here" # Your HTTP server, Apache/etc diff --git a/lib/capistrano/recipes/deploy.rb b/lib/capistrano/recipes/deploy.rb index 0af57bb4..b7b9f889 100644 --- a/lib/capistrano/recipes/deploy.rb +++ b/lib/capistrano/recipes/deploy.rb @@ -23,7 +23,7 @@ _cset(:repository) { abort "Please specify the repository that houses your appl # are not sufficient. # ========================================================================= -_cset :scm, :subversion +_cset :scm, scm_default _cset :deploy_via, :checkout _cset(:deploy_to) { "/u/apps/#{application}" } @@ -80,6 +80,33 @@ _cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_r # These are helper methods that will be available to your recipes. # ========================================================================= +# Checks known version control directories to intelligently set the version +# control in-use. For example, if a .svn directory exists in the project, +# it will set the :scm variable to :subversion, if a .git directory exists +# in the project, it will set the :scm variable to :git and so on. If no +# directory is found, it will default to :git. +def scm_default + if File.exist? '.git' + :git + elsif File.exist? '.accurev' + :accurev + elsif File.exist? '.bzr' + :bzr + elsif File.exist? '.cvs' + :cvs + elsif File.exist? '_darcs' + :darcs + elsif File.exist? '.hg' + :mercurial + elsif File.exist? '.perforce' + :perforce + elsif File.exist? '.svn' + :subversion + else + :none + end +end + # Auxiliary helper method for the `deploy:check' task. Lets you set up your # own dependencies. def depend(location, type, *args)