Skip to content

Commit

Permalink
Ensure that a custom committer, if given, makes it into the git commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
nreckart committed Dec 5, 2011
1 parent e8f0e27 commit 535cc32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/gaga.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ def head
# Commits the the value into the git repository with the given commit message
def save(options)
author = options[:author] ? Grit::Actor.new(options[:author][:name], options[:author][:email]) : nil
committer = options[:committer] ? Grit::Actor.new(options[:committer][:name], options[:committer][:email]) : nil

index = git.index
if head
commit = head.commit
index.current_tree = commit.tree
end
yield index
index.commit(options[:message], :parents => Array(commit), :author => author, :head => branch) if index.tree.any?
index.commit(options[:message], :parents => Array(commit), :author => author, :committer => committer, :head => branch) if index.tree.any?
end

# Converts the value to yaml format
Expand Down
8 changes: 7 additions & 1 deletion test/gaga_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@
end

it "writes String values to keys with global custom log data" do
store = Gaga.new(:repo => tmp_dir, :branch => :lady, :author => {:name => 'Test', :email => 'test@example.com'})
store = Gaga.new(
:repo => tmp_dir,
:branch => :lady,
:author => {:name => 'Test', :email => 'test@example.com'},
:committer => {:name => 'Test2', :email => 'test2@example.com'}
)

store.set(key, "value", {:message => "Custom message"})
store[key].must_equal "value"

entry = store.log(key).first
entry['message'].must_equal "Custom message"
entry['author'].must_equal({'name' => 'Test', 'email' => 'test@example.com'})
entry['committer'].must_equal({'name' => 'Test2', 'email' => 'test2@example.com'})
end

it "does not create empty commit" do
Expand Down

1 comment on commit 535cc32

@jamew
Copy link

@jamew jamew commented on 535cc32 Aug 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do u get on to play

Please sign in to comment.