Skip to content

Instantly share code, notes, and snippets.

@alediaferia
Last active May 9, 2016 20:31
Show Gist options
  • Save alediaferia/d12bc8b906725e79219a to your computer and use it in GitHub Desktop.
Save alediaferia/d12bc8b906725e79219a to your computer and use it in GitHub Desktop.
Capistrano strategy for checking out git projects locally rather than on deployment destination machine
module LocalGitStrategy
def test
run_locally do
test " [ -f #{repo_path}/.git/HEAD ] "
end
end
def check
run_locally do
execute :git, :'ls-remote --heads', repo_url
end
end
def clone
run_locally do
execute :git, :clone, repo_url, repo_path
end
end
def update
run_locally do
within repo_path do
execute :git, :remote, :update
end
end
end
def release
# no op
end
def fetch_revision
run_locally do
within repo_path do
capture(:git, :'rev-list', '--max-count=1', :'--abbrev-commit', "#{fetch(:branch)}")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment