Permalink
Browse files

Avoid creating commits if there are no changes

  • Loading branch information...
1 parent f290a5f commit 24ff408e8ca8db6d687ea8a28ced516fd6234663 @bkeepers committed Aug 31, 2011
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/adapter/git.rb
  2. +7 −0 spec/git_spec.rb
View
2 lib/adapter/git.rb
@@ -70,7 +70,7 @@ def commit(message)
yield index
- index.commit(message, :parents => Array(commit), :head => branch)
+ index.commit(message, :parents => Array(commit), :head => branch) unless index.tree.empty?
end
end
View
7 spec/git_spec.rb
@@ -34,6 +34,13 @@
adapter.get('foo').should be_nil
end
+ it 'should not generate a commit message if there are no changes' do
+ adapter.clear
+ head = adapter.head.commit
+ adapter.clear
+ adapter.head.commit.id.should == head.id
+ end
+
context 'with the path option' do
before do
adapter.options[:path] = 'db/things'

0 comments on commit 24ff408

Please sign in to comment.