Class: Capistrano::SCM::GitWithSubmoduleAndResolvSymlinks
- Inherits:
-
Plugin
- Object
- Plugin
- Capistrano::SCM::GitWithSubmoduleAndResolvSymlinks
- Defined in:
- lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb,
lib/capistrano/scm/git_with_submodule_and_resolv_symlinks/version.rb
Constant Summary collapse
- VERSION =
"0.3.3"
Instance Method Summary collapse
- #check_repo_is_reachable ⇒ Object
- #clone_repo ⇒ Object
- #define_tasks ⇒ Object
- #fetch_revision ⇒ Object
- #git(*args) ⇒ Object
- #git_repo_url ⇒ Object
- #nsp ⇒ Object
- #real_branch ⇒ Object
- #register_hooks ⇒ Object
- #release ⇒ Object
- #repo_mirror_exists? ⇒ Boolean
- #set_defaults ⇒ Object
- #update_mirror ⇒ Object
Instance Method Details
#check_repo_is_reachable ⇒ Object
44 45 46 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 44 def check_repo_is_reachable git :'ls-remote', git_repo_url, "HEAD" end |
#clone_repo ⇒ Object
48 49 50 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 48 def clone_repo git :clone, git_repo_url, repo_path.to_s end |
#define_tasks ⇒ Object
36 37 38 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 36 def define_tasks eval_rakefile File.("../tasks/git_with_submodule_and_resolv_symlinks.rake", __FILE__) end |
#fetch_revision ⇒ Object
67 68 69 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 67 def fetch_revision backend.capture(:git, "rev-list", "--max-count=1", real_branch) end |
#git(*args) ⇒ Object
79 80 81 82 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 79 def git(*args) args.unshift :git backend.execute(*args) end |
#git_repo_url ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 84 def git_repo_url if fetch(:git_http_username) && fetch(:git_http_password) URI.parse(repo_url).tap do |repo_uri| repo_uri.user = fetch(:git_http_username) repo_uri.password = CGI.escape(fetch(:git_http_password)) end.to_s elsif fetch(:git_http_username) URI.parse(repo_url).tap do |repo_uri| repo_uri.user = fetch(:git_http_username) end.to_s else repo_url end end |
#nsp ⇒ Object
10 11 12 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 10 def nsp "git_with_submodule_and_resolv_symlinks" end |
#real_branch ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 71 def real_branch @real_branch ||= if backend.test(:git, :"rev-parse", "origin/#{fetch(:branch)}") "origin/#{fetch(:branch)}" else fetch(:branch) end end |
#register_hooks ⇒ Object
29 30 31 32 33 34 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 29 def register_hooks nsp = "git_with_submodule_and_resolv_symlinks" after "deploy:new_release_path", "#{nsp}:create_release" before "deploy:check", "#{nsp}:check" before "deploy:set_current_revision", "#{nsp}:set_current_revision" end |
#release ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 59 def release if fetch(:repo_tree) backend.execute "rsync -ar --copy-links --exclude=.git\* #{repo_path}/#{fetch(:repo_tree)}/ #{release_path}" else backend.execute "rsync -ar --copy-links --exclude=.git\* #{repo_path}/ #{release_path}" end end |
#repo_mirror_exists? ⇒ Boolean
40 41 42 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 40 def repo_mirror_exists? backend.test " [ -d #{repo_path}/.git ] " end |
#set_defaults ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 14 def set_defaults set_if_empty :"#{nsp}_wrapper_path", lambda { # Try to avoid permissions issues when multiple users deploy the same app # by using different file names in the same dir for each deployer and stage. suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-") "#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh" } set_if_empty :"#{nsp}_environmental_variables", lambda { { git_askpass: "/bin/echo", git_ssh: fetch(:"#{nsp}_wrapper_path") } } end |
#update_mirror ⇒ Object
52 53 54 55 56 57 |
# File 'lib/capistrano/scm/git_with_submodule_and_resolv_symlinks.rb', line 52 def update_mirror git :remote, "set-url", "origin", git_repo_url git :remote, :update, "--prune" git :checkout, "--detach", real_branch git :submodule, :update, "--init" end |