From 612d5c4284c6c7866f1222504d07275bda72a538 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Wed, 6 Jun 2012 13:32:07 -0500 Subject: [PATCH 1/4] Template fix --- data/deploy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/deploy.rb b/data/deploy.rb index ab26db19..36c9680c 100644 --- a/data/deploy.rb +++ b/data/deploy.rb @@ -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' From ee859e03ae2124d7e9878c6ddcd33e3912d61344 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Wed, 6 Jun 2012 13:40:48 -0500 Subject: [PATCH 2/4] Ignore generated packages --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 201d33b1..a190bb83 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ doc test_env/deploy .rvmrc Gemfile.lock +pkg/ From 6918a4df01b37fd9871c07a6cfeabf0a66837856 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Wed, 6 Jun 2012 14:07:18 -0500 Subject: [PATCH 3/4] Check if git revision is empty --- lib/mina/git.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/mina/git.rb b/lib/mina/git.rb index 831469ef..6e1178c9 100644 --- a/lib/mina/git.rb +++ b/lib/mina/git.rb @@ -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]} && From 21c8c12a0d20a38880474669fbf2eb28c470fb60 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Wed, 6 Jun 2012 14:40:21 -0500 Subject: [PATCH 4/4] Test git integration --- spec/commands/git_spec.rb | 22 ++++++++++++++++++++++ spec/fixtures/empty_env/config/deploy.rb | 15 +++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 spec/commands/git_spec.rb create mode 100644 spec/fixtures/empty_env/config/deploy.rb diff --git a/spec/commands/git_spec.rb b/spec/commands/git_spec.rb new file mode 100644 index 00000000..1d0f3502 --- /dev/null +++ b/spec/commands/git_spec.rb @@ -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 diff --git a/spec/fixtures/empty_env/config/deploy.rb b/spec/fixtures/empty_env/config/deploy.rb new file mode 100644 index 00000000..da8cfe9c --- /dev/null +++ b/spec/fixtures/empty_env/config/deploy.rb @@ -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