Module: Capistrano::RsyncScm::GitStrategy

Defined in:
lib/capistrano/rsync_scm.rb

Overview

The Capistrano default strategy for git. You should want to use this.

Instance Method Summary collapse

Instance Method Details

#checkObject



12
13
14
# File 'lib/capistrano/rsync_scm.rb', line 12

def check
  `git ls-remote #{fetch(:repo_url)} refs/heads/#{fetch(:branch)} || true`.lines.any?
end

#fetch_revisionObject



28
29
30
# File 'lib/capistrano/rsync_scm.rb', line 28

def fetch_revision
  `git rev-parse --short #{fetch(:branch)}`
end

#with_clone(&block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/capistrano/rsync_scm.rb', line 16

def with_clone(&block)
  tmpdir = Dir.mktmpdir('capistrano-rsync-scm-')
  begin
    run_locally do
      execute :git, 'clone', '--quiet', "--branch=#{fetch(:branch)}", fetch(:repo_url), tmpdir
    end
    block.call(tmpdir)
  ensure
    FileUtils.remove_entry(tmpdir)
  end
end