Skip to content

Commit

Permalink
added patch from eric goodwin for stashes and unit tests for stashes
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Mar 3, 2008
1 parent bc09a70 commit 2d749e3
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/git/branch.rb
Expand Up @@ -12,8 +12,6 @@ def initialize(base, name)
@full = name
@base = base

@stashes = Git::Stashes.new(@base)

parts = name.split('/')
if parts[1]
@remote = Git::Remote.new(@base, parts[0])
Expand Down
49 changes: 49 additions & 0 deletions tests/units/test_each_conflict.rb
@@ -0,0 +1,49 @@
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../test_helper'

class TestEachConflict < Test::Unit::TestCase

def setup
set_file_paths
#@git = Git.open(@wdir, :log => Logger.new(STDOUT))
@git = Git.open(@wdir)
end

def test_conflicts
in_temp_dir do |path|
g = Git.clone(@wbare, 'branch_merge_test')
Dir.chdir('branch_merge_test') do

g.branch('new_branch').in_branch('test') do
new_file('example.txt', "1\n2\n3")
g.add
true
end

g.branch('new_branch2').in_branch('test') do
new_file('example.txt', "1\n4\n3")
g.add
true
end


g.merge('new_branch')
begin
g.merge('new_branch2')
rescue
end

g.each_conflict do |file, your, their|
assert_equal('example.txt', file)
assert_equal("1\n2\n3\n", File.read(your))
assert_equal("1\n4\n3\n", File.read(their))
end

end
end
end



end
36 changes: 36 additions & 0 deletions tests/units/test_stashes.rb
@@ -0,0 +1,36 @@
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../test_helper'

class TestStashes < Test::Unit::TestCase
def setup
set_file_paths
end

def test_stash_unstash
in_temp_dir do |path|
g = Git.clone(@wbare, 'stash_test')
Dir.chdir('stash_test') do
assert_equal(0, g.branch.stashes.size)
new_file('test-file1', 'blahblahblah1')
new_file('test-file2', 'blahblahblah2')
assert(g.status.untracked.assoc('test-file1'))

g.add

assert(g.status.added.assoc('test-file1'))

g.branch.stashes.save('testing')

g.reset
assert_nil(g.status.untracked.assoc('test-file1'))
assert_nil(g.status.added.assoc('test-file1'))

g.branch.stashes.apply

assert(g.status.added.assoc('test-file1'))
end
end
end

end

0 comments on commit 2d749e3

Please sign in to comment.