Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

rake:release should notify of both unstaged and uncommitted changes #2088

Merged
merged 1 commit into from Feb 19, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/bundler/gem_helper.rb
Expand Up @@ -112,13 +112,17 @@ def guard_already_tagged
end

def guard_clean
clean? or raise("There are files that need to be committed first.")
clean? && committed? or raise("There are files that need to be committed first.")
end

def clean?
sh_with_code("git diff --exit-code")[1] == 0
end

def committed?
sh_with_code("git diff-index --quiet --cached HEAD")[1] == 0
end

def tag_version
sh "git tag -a -m \"Version #{version}\" #{version_tag}"
Bundler.ui.confirm "Tagged #{version_tag}"
Expand Down
5 changes: 5 additions & 0 deletions spec/bundler/gem_helper_spec.rb
Expand Up @@ -128,7 +128,12 @@ def mock_build_message
end

describe 'release' do
it "shouldn't push if there are unstaged files" do
proc { @helper.release_gem }.should raise_error(/files that need to be committed/)
end

it "shouldn't push if there are uncommitted files" do
%x{cd test; git add .}
proc { @helper.release_gem }.should raise_error(/files that need to be committed/)
end

Expand Down