Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test git #2

Merged
merged 4 commits into from
Jun 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ doc
test_env/deploy
.rvmrc
Gemfile.lock
pkg/
4 changes: 2 additions & 2 deletions data/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
set :domain, 'foobar.com'
set :deploy_to, '/var/www/foobar.com'
set :repository, 'git://...'
# set :user, 'foobar.com'
# set :user, 'foobar'

desc "Deploys the current version to the server."
task :deploy do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:checkout'
invoke :'git:clone'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
Expand Down
5 changes: 5 additions & 0 deletions lib/mina/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
task :clone do
settings.revision ||= `git rev-parse HEAD`.strip

if settings.revision.empty?
error "Git revision is empty. Check if you are in git tree."
exit 1
end

queue %{
echo "-----> Cloning the Git repository"
#{echo_cmd %[git clone "#{repository!}" . -n --recursive]} &&
Expand Down
22 changes: 22 additions & 0 deletions spec/commands/git_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'
require 'command_helper'

describe "Invoking the 'mina deploy' command outside of git tree" do
before do
temp_path = "/tmp/mina-spec"
FileUtils.mkdir_p("#{temp_path}/config")
FileUtils.cp root('spec/fixtures/empty_env/config/deploy.rb'), "#{temp_path}/config/deploy.rb"
Dir.chdir temp_path
end

after do
FileUtils.rm_rf "/tmp/mina-spec"
Dir.chdir root
end

it 'should prompt empty revision error message' do
run_command 'deploy', 'simulate=1'
exitstatus.should_not eq(0)
stderr.should match(/git revision is empty/i)
end
end
15 changes: 15 additions & 0 deletions spec/fixtures/empty_env/config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'fileutils'
FileUtils.mkdir_p "#{Dir.pwd}/deploy"

require 'mina/git'

set :domain, 'localhost'
set :deploy_to, "#{Dir.pwd}/deploy"
set :repository, "#{Dir.pwd}"

desc "Deploys."
task :deploy do
deploy do
invoke :'git:clone'
end
end