Permalink
Browse files

Use more intelligence in setting the :scm variable based on known ver…

…sion control directory names
  • Loading branch information...
David Czarnecki
David Czarnecki committed Jun 28, 2012
1 parent e82de1c commit 26490e97f3680d8f65ec509c8edca168272c7376
Showing with 29 additions and 2 deletions.
  1. +1 −1 bin/capify
  2. +28 −1 lib/capistrano/recipes/deploy.rb
View
@@ -51,7 +51,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
@@ -22,7 +22,7 @@ def _cset(name, *args, &block)
# are not sufficient.
# =========================================================================
-_cset :scm, :subversion
+_cset :scm, scm_default
_cset :deploy_via, :checkout
_cset(:deploy_to) { "/u/apps/#{application}" }
@@ -79,6 +79,33 @@ def _cset(name, *args, &block)
# 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)

0 comments on commit 26490e9

Please sign in to comment.