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

pushes HEAD if tag pattern matching fails #115

Merged
merged 1 commit into from
Nov 24, 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
4 changes: 3 additions & 1 deletion lib/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require 'rake/dsl_definition'

module Git
class NoTagFoundError < Exception; end

include Rake::DSL

def git_clone(repos, dir)
Expand Down Expand Up @@ -34,7 +36,7 @@ def git_rev_parse(ref)

def git_tag(glob)
return nil if glob.nil?
%x{git tag -l '#{glob}'}.split("\n").last
%x{git tag -l '#{glob}'}.split("\n").last || (raise NoTagFoundError, "No tag found [#{glob}]")
end

def git_revision(repo)
Expand Down
8 changes: 5 additions & 3 deletions spec/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ class GitTest; include Git; end
subject.should_receive("`").with("git tag -l 'pattern*'") { "x\n\y\n\z\n" }
subject.git_tag('pattern*').should == "z"
end
it "returns nil if no tags match the pattern" do
it "raises exception if no tags match the pattern" do
subject.should_receive("`").with("git tag -l 'pattern*'") { "\n" }
subject.git_tag('pattern*').should == nil
expect {
subject.git_tag('pattern*')
}.to raise_error(Git::NoTagFoundError)
end
it "returns nil for a nil tag" do
it "returns nil for a nil glob" do
subject.should_not_receive("`").with("git tag -l ''") { "\n" }
subject.git_tag(nil).should == nil
end
Expand Down
6 changes: 4 additions & 2 deletions spec/heroku_san/stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@

describe "#push" do
it "deploys to heroku" do
subject.should_receive(:git_push).with(git_parsed_tag(subject.tag), subject.repo, [])
subject.should_receive(:git_parsed_tag).with(nil) {'tag'}
subject.should_receive(:git_push).with('tag', subject.repo, [])
subject.push
end

Expand All @@ -89,7 +90,8 @@
end

it "deploys with --force" do
subject.should_receive(:git_push).with(git_parsed_tag(subject.tag), subject.repo, %w[--force])
subject.should_receive(:git_parsed_tag).with(nil) {'tag'}
subject.should_receive(:git_push).with('tag', subject.repo, %w[--force])
subject.push(nil, :force)
end

Expand Down