Skip to content

Commit

Permalink
Be less annoying
Browse files Browse the repository at this point in the history
  • Loading branch information
erithmetic committed Jan 17, 2011
1 parent ac6371d commit 6b54bc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
17 changes: 12 additions & 5 deletions lib/bueller/commands/release_to_github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ def version; bueller.version; end
def repo; bueller.repo; end

def run
raise "Hey buddy, try committing them files first" unless clean_staging_area?

repo.checkout('master')
run = true
unless clean_staging_area?
puts "There are some modified files that haven't been committed. Proceed anyway?"
run = $stdin.gets =~ /(y|yes)/i ? true : false
end
if run
repo.checkout('master')

output.puts "Pushing master to origin"
repo.push
output.puts "Pushing master to origin"
repo.push
else
raise "Release cancelled"
end
end

def clean_staging_area?
Expand Down
13 changes: 8 additions & 5 deletions spec/bueller/commands/release_to_github_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
command.stub!(:release_tagged?).and_return true
end

it 'should raise an error if the staging area is unclean' do
it 'should push if the staging area is unclean and the use elects to proceed' do
command.stub!(:clean_staging_area?).and_return false
expect { command.run }.should raise_error(RuntimeError, /try committing/i)
end
it 'should check out master' do
command.repo.should_receive(:checkout).with 'master'
$stdin.stub!(:gets).and_return 'y'
command.repo.should_receive :push
command.run
end
it 'should raise an error if the staging area is unclean and the use elects not to proceed' do
command.stub!(:clean_staging_area?).and_return false
$stdin.stub!(:gets).and_return 'n'
expect { command.run }.should raise_error(RuntimeError, /cancel/i)
end
it 'should push' do
command.repo.should_receive :push
command.run
Expand Down

0 comments on commit 6b54bc6

Please sign in to comment.