summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Chacon <schacon@gmail.com>2008-03-03 14:47:01 -0800
committerScott Chacon <schacon@gmail.com>2008-03-03 14:47:01 -0800
commit2d749e3aa69d7bfedf814f59618f964fdbc300d5 (patch)
tree1f90a2b94dd097c227fcd0dcc2d2eaab9725621c
parentbc09a701262425adee32030c3b25f8b1c0be776e (diff)
downloadthird_party-ruby-git-2d749e3aa69d7bfedf814f59618f964fdbc300d5.zip
third_party-ruby-git-2d749e3aa69d7bfedf814f59618f964fdbc300d5.tar.gz
third_party-ruby-git-2d749e3aa69d7bfedf814f59618f964fdbc300d5.tar.xz
added patch from eric goodwin for stashes and unit tests for stashes
-rw-r--r--lib/git/branch.rb2
-rw-r--r--tests/units/test_each_conflict.rb49
-rw-r--r--tests/units/test_stashes.rb36
3 files changed, 85 insertions, 2 deletions
diff --git a/lib/git/branch.rb b/lib/git/branch.rb
index 5dc8ec7..5b8ff63 100644
--- a/lib/git/branch.rb
+++ b/lib/git/branch.rb
@@ -12,8 +12,6 @@ module Git
@full = name
@base = base
- @stashes = Git::Stashes.new(@base)
-
parts = name.split('/')
if parts[1]
@remote = Git::Remote.new(@base, parts[0])
diff --git a/tests/units/test_each_conflict.rb b/tests/units/test_each_conflict.rb
new file mode 100644
index 0000000..c5c9bb4
--- /dev/null
+++ b/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 \ No newline at end of file
diff --git a/tests/units/test_stashes.rb b/tests/units/test_stashes.rb
new file mode 100644
index 0000000..2306061
--- /dev/null
+++ b/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 \ No newline at end of file