Last active
May 9, 2016 20:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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