summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 11:03:03 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 11:03:03 -0800
commit440ec51cded64d49c5c2aae949401dd60e4b876d (patch)
tree2c5ea51e59e724203e7aceeed7d15d7b71d36690
parenta4fa110279ea28873fe1e4df10c89ddc591046b4 (diff)
downloadthird_party-ruby-git-440ec51cded64d49c5c2aae949401dd60e4b876d.zip
third_party-ruby-git-440ec51cded64d49c5c2aae949401dd60e4b876d.tar.gz
third_party-ruby-git-440ec51cded64d49c5c2aae949401dd60e4b876d.tar.xz
fixed a small environment bug
-rw-r--r--lib/git/lib.rb8
-rw-r--r--tests/units/test_config.rb2
-rw-r--r--tests/units/test_index.rb77
3 files changed, 5 insertions, 82 deletions
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index d0dda8b..d857253 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -39,7 +39,7 @@ module Git
#
def clone(repository, name, opts = {})
@path = opts[:path] || '.'
- clone_dir = File.join(@path, name)
+ opts[:path] ? clone_dir = File.join(@path, name) : clone_dir = name
arr_opts = []
arr_opts << "--bare" if opts[:bare]
@@ -225,9 +225,9 @@ module Git
end
def command(cmd, opts = {})
- ENV['GIT_DIR'] = @git_dir if @git_dir
- ENV['GIT_INDEX_FILE'] = @git_index_file if @git_index_file
- ENV['GIT_WORK_DIR'] = @git_work_dir if @git_work_dir
+ ENV['GIT_DIR'] = @git_dir
+ ENV['GIT_INDEX_FILE'] = @git_index_file
+ ENV['GIT_WORK_DIR'] = @git_work_dir
path = @git_work_dir || @git_dir || @path
Dir.chdir(path) do
opts = opts.to_a.join(' ')
diff --git a/tests/units/test_config.rb b/tests/units/test_config.rb
index 66dc9ff..46ccd1e 100644
--- a/tests/units/test_config.rb
+++ b/tests/units/test_config.rb
@@ -2,7 +2,7 @@
require File.dirname(__FILE__) + '/../test_helper'
-class TestBranch < Test::Unit::TestCase
+class TestConfig < Test::Unit::TestCase
def setup
set_file_paths
@git = Git.open(@wdir)
diff --git a/tests/units/test_index.rb b/tests/units/test_index.rb
deleted file mode 100644
index b4e2f81..0000000
--- a/tests/units/test_index.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../test_helper'
-
-class TestIndex< Test::Unit::TestCase
-
- def setup
- set_file_paths
- @git = Git.open(@wdir)
- end
-
- def test_add
- in_temp_dir do |path|
- g = Git.clone(@wbare, 'new')
- Dir.chdir('new') do
- puts `pwd`
- #assert_equal('100644', g.status['example.txt'].mode_index)
-
- new_file('test-file', 'blahblahblah')
- assert(g.status.untracked.assoc('test-file'))
-
- g.add
- assert(g.status.added.assoc('test-file'))
- assert(!g.status.untracked.assoc('test-file'))
- assert(!g.status.changed.assoc('example.txt'))
-
- append_file('example.txt', 'hahahaha')
- puts g.status.pretty
- assert(g.status.changed.assoc('example.txt'))
-
- g.add
- assert(g.status.changed.assoc('example.txt'))
-
- g.commit('my message')
- assert(!g.status.changed.assoc('example.txt'))
- assert(!g.status.added.assoc('test-file'))
- assert(!g.status.untracked.assoc('test-file'))
- assert_equal('hahahaha', g.status['example.txt'].blob.contents)
- end
- end
- end
-
- def test_add_array
- in_temp_dir do |path|
- g = Git.clone(@wbare, 'new')
- Dir.chdir('new') do
-
- new_file('test-file1', 'blahblahblah1')
- new_file('test-file2', 'blahblahblah2')
- assert(g.status.untracked.assoc('test-file1'))
-
- g.add(['test-file1', 'test-file2'])
- assert(g.status.added.assoc('test-file1'))
- assert(g.status.added.assoc('test-file1'))
- assert(!g.status.untracked.assoc('test-file1'))
-
- g.commit('my message')
- assert(!g.status.added.assoc('test-file1'))
- assert(!g.status.untracked.assoc('test-file1'))
- assert_equal('blahblahblah1', g.status['test-file1'].blob.contents)
- end
- end
- end
-
- def new_file(name, contents)
- File.open(name, 'w') do |f|
- f.puts contents
- end
- end
-
- def append_file(name, contents)
- File.open(name, 'a') do |f|
- f.puts contents
- end
- end
-
-end \ No newline at end of file