shelly 0.1.38 → 0.1.39
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/shelly/app.rb +17 -1
- data/lib/shelly/cli/deploy.rb +17 -0
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/app_spec.rb +23 -1
- data/spec/shelly/cli/deploy_spec.rb +37 -1
- data/spec/shelly/cli/main_spec.rb +2 -2
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.1.39 / 2013-01-08
|
2
|
+
|
3
|
+
* [feature] Added `shelly deploys pending` - displays a list of commits which are not deployed to Shelly Cloud yet.
|
4
|
+
|
1
5
|
## 0.1.38 / 2012-12-20
|
2
6
|
|
3
7
|
* [improvement] Using logs streaming server for logs tail (`shelly logs -f`). Logs are displayed more fluently.
|
data/lib/shelly/app.rb
CHANGED
@@ -211,7 +211,7 @@ module Shelly
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def edit_billing_url
|
214
|
-
"#{shelly.shellyapp_url}/
|
214
|
+
"#{shelly.shellyapp_url}/organizations/#{attributes["organization_name"]}/edit"
|
215
215
|
end
|
216
216
|
|
217
217
|
def open
|
@@ -261,6 +261,22 @@ module Shelly
|
|
261
261
|
cloud_databases - ['redis']
|
262
262
|
end
|
263
263
|
|
264
|
+
# Public: Return true when app has been deployed
|
265
|
+
# false otherwise
|
266
|
+
def deployed?
|
267
|
+
git_info["deployed_commit_sha"].present?
|
268
|
+
end
|
269
|
+
|
270
|
+
# Public: Return list of not deployed commits
|
271
|
+
# Returns: A list of commits as a String with new line chars
|
272
|
+
# format: "#{short SHA} #{commit message} (#{time, ago notation})"
|
273
|
+
def pending_commits
|
274
|
+
current_commit = IO.popen("git rev-parse 'HEAD'").read.strip
|
275
|
+
format = "%C(yellow)%h%Creset %s %C(red)(%cr)%Creset"
|
276
|
+
range = "#{git_info["deployed_commit_sha"]}..#{current_commit}"
|
277
|
+
IO.popen(%Q{git log --no-merges --oneline --pretty=format:"#{format}" #{range}}).read.strip
|
278
|
+
end
|
279
|
+
|
264
280
|
private
|
265
281
|
|
266
282
|
# Internal: Checks if specified option is present in Cloudfile
|
data/lib/shelly/cli/deploy.rb
CHANGED
@@ -8,6 +8,7 @@ module Shelly
|
|
8
8
|
include Helpers
|
9
9
|
|
10
10
|
before_hook :logged_in?, :only => [:list, :show]
|
11
|
+
before_hook :inside_git_repository?, :only => [:pending]
|
11
12
|
class_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
|
12
13
|
|
13
14
|
desc "list", "Lists deploy logs"
|
@@ -56,6 +57,22 @@ module Shelly
|
|
56
57
|
say_error "Log not found, list all deploy logs using `shelly deploys list --cloud=#{app.code_name}`"
|
57
58
|
end
|
58
59
|
|
60
|
+
desc "pending", "Show commits which haven't been deployed yet"
|
61
|
+
def pending
|
62
|
+
app = multiple_clouds(options[:cloud], "deploy pending")
|
63
|
+
if app.deployed?
|
64
|
+
commits = app.pending_commits
|
65
|
+
if commits.present?
|
66
|
+
say "Commits which are not deployed to Shelly"
|
67
|
+
say commits
|
68
|
+
else
|
69
|
+
say "All changes are deployed to Shelly", :green
|
70
|
+
end
|
71
|
+
else
|
72
|
+
say_error "No commits to show. Application hasn't been deployed yet"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
59
76
|
no_tasks do
|
60
77
|
def specify_log(log)
|
61
78
|
unless log
|
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -328,7 +328,8 @@ describe Shelly::App do
|
|
328
328
|
|
329
329
|
describe "#edit_billing_url" do
|
330
330
|
it "should return link to edit billing page for app" do
|
331
|
-
@app.
|
331
|
+
@app.stub(:attributes).and_return({"organization_name" => "example"})
|
332
|
+
@app.edit_billing_url.should == "http://shellyapp.example.com/organizations/example/edit"
|
332
333
|
end
|
333
334
|
end
|
334
335
|
|
@@ -447,4 +448,25 @@ describe Shelly::App do
|
|
447
448
|
out.should == "GET / 127.0.0.1"
|
448
449
|
end
|
449
450
|
end
|
451
|
+
|
452
|
+
describe "#deployed?" do
|
453
|
+
it "should return true when app has been deployed" do
|
454
|
+
@app.stub(:attributes => {"git_info" => {"deployed_commit_sha" => "d1b8bec"}})
|
455
|
+
@app.should be_deployed
|
456
|
+
end
|
457
|
+
|
458
|
+
it "should return false when app hasn't been deployed yet" do
|
459
|
+
@app.stub(:attributes => {"git_info" => {"deployed_commit_sha" => ""}})
|
460
|
+
@app.should_not be_deployed
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
describe "#pending_commits" do
|
465
|
+
it "should return list of not deployed commits" do
|
466
|
+
IO.stub_chain(:popen, :read => "c10c5f6\n")
|
467
|
+
IO.should_receive(:popen).with(%Q{git log --no-merges --oneline --pretty=format:\"%C(yellow)%h%Creset %s %C(red)(%cr)%Creset\" c213697..c10c5f6}).and_return(mock(:read => "c10c5f6 Some changes\n"))
|
468
|
+
@app.stub(:attributes => {"git_info" => {"deployed_commit_sha" => "c213697"}})
|
469
|
+
@app.pending_commits.should == "c10c5f6 Some changes"
|
470
|
+
end
|
471
|
+
end
|
450
472
|
end
|
@@ -103,7 +103,43 @@ describe Shelly::CLI::Deploy do
|
|
103
103
|
"whenever" => "Looking up schedule.rb", "thin_restart" => "thins up and running",
|
104
104
|
"delayed_job" => "delayed jobs", "callbacks" => "rake db:migrate"}
|
105
105
|
end
|
106
|
-
|
107
106
|
end
|
108
107
|
|
108
|
+
describe "#pending" do
|
109
|
+
before do
|
110
|
+
@app.stub(:deployed? => true)
|
111
|
+
@deploys.stub(:multiple_clouds => @app)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should ensure that user is inside git repo" do
|
115
|
+
hooks(@deploys, :pending).should include(:inside_git_repository?)
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when application has been deployed" do
|
119
|
+
context "and has pending commits to deploy" do
|
120
|
+
it "should display them" do
|
121
|
+
text = "643124c Something (2 days ago)\nd1b8bec Something new (10 days ago)"
|
122
|
+
$stdout.should_receive(:puts).with(text)
|
123
|
+
@app.stub(:pending_commits => text)
|
124
|
+
invoke(@deploys, :pending)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "and doesn't have pending commits to deploy" do
|
129
|
+
it "should display a message that everything is deployed" do
|
130
|
+
$stdout.should_receive(:puts).with(green "All changes are deployed to Shelly")
|
131
|
+
@app.stub(:pending_commits => "")
|
132
|
+
invoke(@deploys, :pending)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when application hasn't been deployed" do
|
138
|
+
it "should display error" do
|
139
|
+
@app.stub(:deployed? => false)
|
140
|
+
$stdout.should_receive(:puts).with(red "No commits to show. Application hasn't been deployed yet")
|
141
|
+
lambda { invoke(@deploys, :pending) }.should raise_error(SystemExit)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
109
145
|
end
|
@@ -411,13 +411,13 @@ More info at http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository\e[0m
|
|
411
411
|
end
|
412
412
|
|
413
413
|
it "should create the app on shelly cloud and show trial information" do
|
414
|
-
@app.stub(:attributes).and_return({"trial" => true, "credit" => 40})
|
414
|
+
@app.stub(:attributes).and_return({"trial" => true, "credit" => 40, "organization_name" => "example"})
|
415
415
|
@client.stub(:shellyapp_url).and_return("http://example.com")
|
416
416
|
@app.should_receive(:create)
|
417
417
|
$stdout.should_receive(:puts).with(green "Billing information")
|
418
418
|
$stdout.should_receive(:puts).with("Cloud created with 40 Euro credit.")
|
419
419
|
$stdout.should_receive(:puts).with("Remember to provide billing details before trial ends.")
|
420
|
-
$stdout.should_receive(:puts).with("http://example.com/
|
420
|
+
$stdout.should_receive(:puts).with("http://example.com/organizations/example/edit")
|
421
421
|
|
422
422
|
fake_stdin(["", ""]) do
|
423
423
|
invoke(@main, :add)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.39
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -349,7 +349,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
349
349
|
version: '0'
|
350
350
|
segments:
|
351
351
|
- 0
|
352
|
-
hash:
|
352
|
+
hash: -285970216853493916
|
353
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
354
354
|
none: false
|
355
355
|
requirements:
|
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
358
|
version: '0'
|
359
359
|
segments:
|
360
360
|
- 0
|
361
|
-
hash:
|
361
|
+
hash: -285970216853493916
|
362
362
|
requirements: []
|
363
363
|
rubyforge_project: shelly
|
364
364
|
rubygems_version: 1.8.24
|