Module: Capistrano::Git::DefaultStrategy

Defined in:
lib/capistrano/git.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#checkObject



19
20
21
# File 'lib/capistrano/git.rb', line 19

def check
  git :'ls-remote --heads', repo_url
end

#cloneObject



23
24
25
26
27
28
29
# File 'lib/capistrano/git.rb', line 23

def clone
  if (depth = fetch(:git_shallow_clone))
    git :clone, "--mirror", "--depth", depth, "--no-single-branch", repo_url, repo_path
  else
    git :clone, "--mirror", repo_url, repo_path
  end
end

#fetch_revisionObject



50
51
52
# File 'lib/capistrano/git.rb', line 50

def fetch_revision
  context.capture(:git, "rev-list --max-count=1 #{fetch(:branch)}")
end

#releaseObject



40
41
42
43
44
45
46
47
48
# File 'lib/capistrano/git.rb', line 40

def release
  if (tree = fetch(:repo_tree))
    tree = tree.slice %r#^/?(.*?)/?$#, 1
    components = tree.split("/").size
    git :archive, fetch(:branch), tree, "| tar -x --strip-components #{components} -f - -C", release_path
  else
    git :archive, fetch(:branch), "| tar -x -f - -C", release_path
  end
end

#testObject



15
16
17
# File 'lib/capistrano/git.rb', line 15

def test
  test! " [ -f #{repo_path}/HEAD ] "
end

#updateObject



31
32
33
34
35
36
37
38
# File 'lib/capistrano/git.rb', line 31

def update
  # Note: Requires git version 1.9 or greater
  if (depth = fetch(:git_shallow_clone))
    git :fetch, "--depth", depth, "origin", fetch(:branch)
  else
    git :remote, :update, "--prune"
  end
end