Class: Capistrano::SCM::Svn

Inherits:
Plugin show all
Defined in:
lib/capistrano/scm/svn.rb

Instance Method Summary collapse

Methods inherited from Plugin

#scm?

Methods inherited from Plugin

#set_defaults

Methods included from DSL

#execute, #invoke, #invoke!, #local_user, #lock, #on, #revision_log_message, #rollback_log_message, #run_locally, #scm, #sudo, #t

Methods included from DSL::Stages

#stage_definitions, #stage_set?, #stages

Methods included from DSL::Paths

#asset_timestamp, #current_path, #deploy_config_path, #deploy_path, #deploy_to, #join_paths, #linked_dir_parents, #linked_dirs, #linked_file_dirs, #linked_files, #map_dirnames, #now, #release_path, #releases_path, #repo_path, #repo_url, #revision_log, #set_release_path, #shared_path, #stage_config_path

Methods included from DSL::Env

#asset_timestamp, #env, #release_roles, #release_timestamp, #role_properties, #roles

Methods included from TaskEnhancements

#after, #before, #default_tasks, #define_remote_file_task, #deploying?, #ensure_stage, #exit_deploy_because_of_exception, #tasks_without_stage_dependency

Instance Method Details

#archive_to_release_pathObject



43
44
45
# File 'lib/capistrano/scm/svn.rb', line 43

def archive_to_release_path
  svn :export, "--force", ".", release_path
end

#check_repo_is_reachableObject



26
27
28
29
30
# File 'lib/capistrano/scm/svn.rb', line 26

def check_repo_is_reachable
  svn_username = fetch(:svn_username) ? "--username #{fetch(:svn_username)}" : ""
  svn_password = fetch(:svn_password) ? "--password #{fetch(:svn_password)}" : ""
  backend.test :svn, :info, repo_url, svn_username, svn_password
end

#clone_repoObject



32
33
34
# File 'lib/capistrano/scm/svn.rb', line 32

def clone_repo
  svn :checkout, repo_url, repo_path.to_s
end

#define_tasksObject



10
11
12
# File 'lib/capistrano/scm/svn.rb', line 10

def define_tasks
  eval_rakefile File.expand_path("../tasks/svn.rake", __FILE__)
end

#fetch_repo_mirror_urlObject



51
52
53
54
55
# File 'lib/capistrano/scm/svn.rb', line 51

def fetch_repo_mirror_url
  backend.capture(:svn, :info, repo_path.to_s).each_line do |line|
    return $1 if /\AURL: (.*)\n\z/ =~ line
  end
end

#fetch_revisionObject



47
48
49
# File 'lib/capistrano/scm/svn.rb', line 47

def fetch_revision
  backend.capture(:svnversion, repo_path.to_s)
end

#register_hooksObject



4
5
6
7
8
# File 'lib/capistrano/scm/svn.rb', line 4

def register_hooks
  after "deploy:new_release_path", "svn:create_release"
  before "deploy:check", "svn:check"
  before "deploy:set_current_revision", "svn:set_current_revision"
end

#repo_mirror_exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/capistrano/scm/svn.rb', line 22

def repo_mirror_exists?
  backend.test " [ -d #{repo_path}/.svn ] "
end

#svn(*args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/capistrano/scm/svn.rb', line 14

def svn(*args)
  args.unshift(:svn)
  args.push "--username #{fetch(:svn_username)}" if fetch(:svn_username)
  args.push "--password #{fetch(:svn_password)}" if fetch(:svn_password)
  args.push "--revision #{fetch(:svn_revision)}" if fetch(:svn_revision)
  backend.execute(*args)
end

#update_mirrorObject



36
37
38
39
40
41
# File 'lib/capistrano/scm/svn.rb', line 36

def update_mirror
  # Switch the repository URL if necessary.
  repo_mirror_url = fetch_repo_mirror_url
  svn :switch, repo_url unless repo_mirror_url == repo_url
  svn :update
end