Skip to content

Instantly share code, notes, and snippets.

@drbraden
Forked from alediaferia/git_local.rb
Created May 9, 2016 20:31
Show Gist options
  • Save drbraden/3fb5f06e4fdf1ceb9e078b063da25e5b to your computer and use it in GitHub Desktop.
Save drbraden/3fb5f06e4fdf1ceb9e078b063da25e5b 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