Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Adding Ruby 2.1.2 to Travis
Browse files Browse the repository at this point in the history
Updating index opts tests to use a Fixnum instead of the 1e4 syntax (Float), no longer supported by Git
git/git@e3fa568c
  • Loading branch information
Roberto Decurnex committed Sep 29, 2014
1 parent 8425a6b commit 13db9b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1
- 2.1.1
- 2.1.2
- jruby-18mode
- jruby-19mode
- ree
Expand Down
30 changes: 13 additions & 17 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -739,31 +739,29 @@ def command(cmd, opts = [], chdir = true, redirect = '', &block)
ENV['GIT_INDEX_FILE'] = @git_index_file

path = @git_work_dir || @git_dir || @path

opts = [opts].flatten.map {|s| escape(s) }.join(' ')

git_cmd = "git #{cmd} #{opts} #{redirect} 2>&1"

out = nil
output = nil

if chdir && (Dir.getwd != path)
Dir.chdir(path) { out = run_command(git_cmd, &block) }
Dir.chdir(path) { output = run_command(git_cmd, &block) }
else

out = run_command(git_cmd, &block)
output = run_command(git_cmd, &block)
end

if @logger
@logger.info(git_cmd)
@logger.debug(out)
@logger.debug(output)
end

if $?.exitstatus > 0
if $?.exitstatus == 1 && out == ''
return ''
end
raise Git::GitExecuteError.new(git_cmd + ':' + out.to_s)
if $?.exitstatus > 1 || ($?.exitstatus == 1 && output != '')
raise Git::GitExecuteError.new(git_cmd + ':' + output.to_s)
end
out

return output
end

# Takes the diff command line output (as Array) and parse it into a Hash
Expand Down Expand Up @@ -821,11 +819,9 @@ def log_path_options(opts)
end

def run_command(git_cmd, &block)
if block_given?
IO.popen(git_cmd, &block)
else
`#{git_cmd}`.chomp
end
return IO.popen(git_cmd, &block) if block_given?

`#{git_cmd}`.chomp
end

def escape(s)
Expand Down
4 changes: 2 additions & 2 deletions tests/units/test_index_ops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def test_revert
g.commit("second-commit")
g.gcommit('HEAD')

commits = g.log(1e4).count
commits = g.log(10000).count
g.revert(first_commit.sha)
assert_equal(commits + 1, g.log(1e4).count)
assert_equal(commits + 1, g.log(10000).count)
assert(!File.exist?('test-file2'))
end
end
Expand Down

0 comments on commit 13db9b9

Please sign in to comment.