Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Base#git_* methods return nil on initial deploy

  • Loading branch information...
commit ca0685921cdc2eb3210e9318067d2cf7f2940f3e 1 parent 103c2bd
@justincampbell justincampbell authored
View
8 lib/capistrano/notifier/base.rb
@@ -18,18 +18,22 @@ def cap
end
def git_current_revision
- cap.current_revision[0,7]
+ cap.current_revision[0,7] if cap.respond_to? :current_revision
end
def git_log
+ return unless git_range
+
`git log #{git_range} --no-merges --format=format:"%h %s (%an)"`
end
def git_previous_revision
- cap.previous_revision[0,7]
+ cap.previous_revision[0,7] if cap.respond_to? :previous_revision
end
def git_range
+ return unless git_previous_revision && git_current_revision
+
"#{git_previous_revision}..#{git_current_revision}"
end
View
9 spec/capistrano/notifier/base_spec.rb
@@ -21,4 +21,13 @@
end
end
end
+
+ describe "#git_*" do
+ context "on initial deploy" do
+ it { subject.send(:git_log).should be_nil }
+ it { subject.send(:git_range).should be_nil }
+ it { subject.send(:git_current_revision).should be_nil }
+ it { subject.send(:git_previous_revision).should be_nil }
+ end
+ end
end

0 comments on commit ca06859

Please sign in to comment.
Something went wrong with that request. Please try again.