lib/cap_reserve.rb in cap_reserve-0.1.7 vs lib/cap_reserve.rb in cap_reserve-0.1.8

- old
+ new

@@ -53,12 +53,13 @@ end desc "Reserve environment using RESERVE=minutes" task :default do begin - env, user, time, force, url, destroy, branch = - ENV['RESERVE_ENV'], ENV['USER'], ENV['RESERVE'], ENV['FORCE'], ENV['RESERVE_URL'], ENV['DESTROY'], ENV['BRANCH'] + env, time, force, url, destroy, branch = + ENV['RESERVE_ENV'], ENV['RESERVE'], ENV['FORCE'], ENV['RESERVE_URL'], ENV['DESTROY'], ENV['BRANCH'] + user = ENV['DEPLOYER'] || ENV['USER'] help = <<-HELP FORCE=1 to deploy anyway DESTROY=1 to deploy and destroy reservation HELP @@ -82,10 +83,10 @@ create.call({}) elsif force create.call(:force => true) else res = get.call("#{url}/reservations/show", :environment => env) - if res['status'] == 'reserved' + if res['status'] == 'reserved' and res['user'] != user puts "\n#{"Reservation exists".red}: #{"#{res['user']}@#{env}".yellow} (#{expires_to_string.call(Time.at(res['expires'])).yellow})\n#{help}\n" exit 0 else create.call({}) end